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

aslak hellesoy aslak.hellesoy at gmail.com
Tue Mar 31 06:34:08 EDT 2009

On Tue, Mar 31, 2009 at 11:34 AM, Josh Chisholm <joshuachisholm at gmail.com>wrote:

> 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?

The result of this block is nil, so that wouldn't work so well...
I'll add a guard against this so you get a better error message.

> 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

That doesn't really solve the problem. It shouldn't be allowed to use the
nil singleton as a World since lots of modules would get mixed into it and
mess things up.

> 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
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090331/3c7bbfbb/attachment.html>

More information about the rspec-users mailing list