Hey all! I'm loving Stories so far, but I ran across a difficult
error today that I felt should have resulted in a "PENDING" message.
Here's what I got:
/Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/spec/
rails/../../../../rspec/lib/spec/story/runner/scenario_runner.rb:11:in
`run': You have a nil object when you didn't expect it! (NoMethodError)
The error occurred while evaluating nil.story from /Users/Malohkan/
Sites/blog/vendor/plugins/rspec_on_rails/lib/spec/rails/
story_adapter.rb:69:in `perform'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/world.rb:52:in
`run_given_scenario_with_suspended_listeners'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/world.rb:101:in
`GivenScenario'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_mediator.rb:
115:in `send'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_mediator.rb:
115:in `to_proc'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_mediator.rb:
95:in `instance_eval'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_mediator.rb:
95:in `to_proc'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_mediator.rb:
95:in `each'
... 6 levels...
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_runner.rb:
39:in `each'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner/story_runner.rb:
39:in `run_stories'
from /Users/Malohkan/Sites/blog/vendor/plugins/rspec_on_rails/lib/
spec/rails/../../../../rspec/lib/spec/story/runner.rb:44:in
`register_exit_hook'
The only thing I could deduce was that it had something to do with
GivenScenario. The problem was that I had misspelled the name of the
Scenario I was trying to run with GivenScenario. However if you
misspell a Step, you get it marked as PENDING and the ones below it as
FAILED.
Once I realize this my first thought was, "Great! A chance to write
my own patch!" Unfortunately I think my rails-fu is still too weak.
I hacked around with it for a while but couldn't duplicate the
behavior like I was hoping. So the best I can do for now is to try to
point those who can in the right direction.
I think that the exception should be caught on line 52 of "world.rb".
The one with "scenario.perform(world, name)" on it. Below in the
following method I see where "step.perform(world, *args)" gets called
and is wrapped with begin/rescue.
If catching the exception isn't the right way to go, then check line
66 of "story_adapter.rb" which has
"StoryRunner.scenario_from_current_story". This call does a .find()
and returns nil. That's the first place it's made known that this
Scenario doesn't exist.
I hope this helps!
Glenn
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users