Confusing error with GivenStory

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:inperform’
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:inGivenScenario’
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:into_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:into_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:ineach’
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:inregister_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

On Mon, Mar 31, 2008 at 11:16 AM, Glenn F. [email protected] wrote:

from
`to_proc’
from
GivenScenario. The problem was that I had misspelled the name of 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!

Please post this to http://rspec.lighthouseapp.com.

Thanks,
David

I sent a reply just a couple minutes later… to myself only :stuck_out_tongue: Sorry
about that. Here what was I sent:

Here’s a lighthouse ticket:
http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/354-confusing-error-with-givenscenario

By the way I just realized I typo’d GivenStory in the subject which
should have been GivenScenario. I guess I’m full of typos today!

Glenn

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs