[rspec-users] [Cucumber] World { nil } causes undefined method `exception=' in backtraces from steps called from other steps

Josh Chisholm joshuachisholm at gmail.com
Tue Mar 31 05:34:50 EDT 2009


We were using the following style of setting up a world:

World do
  def a_helper
    ...
  end
end

I don't know where I came up with that. I now realise we should have
been returning a world class here, but the above style seems to be
supported. Is it?

Anyway, we got away with it so far. And it still works after upgrading
cucumber to 0.2+, but when an exception is raised from a step that is
called by another step, we don't get a full backtrace through the step
definitions, but instead get this cryptic message:

undefined method `exception=' for nil:NilClass (NoMethodError)

Here's the full gist:
http://gist.github.com/87941

FWIW I made the weird message go away:
http://github.com/joshski/cucumber/commit/27a6f718451a417e9d42f9713911e6712aa48e8b

I suspect this solution is wrong because we weren't doing the right
thing. Obviously we can just return a world class like the wiki
suggests. If returning nil from the World block is unsupported, maybe
it should be caught early?

Cheers,

Josh


More information about the rspec-users mailing list