[Cucumber] World { nil } causes undefined method `exception=' in backtraces from steps called from o

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:

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

On Tue, Mar 31, 2009 at 11:34 AM, Josh C.
[email protected]wrote:

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.

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?

Done:
http://github.com/aslakhellesoy/cucumber/commit/6c7f039ac2874775558734108f40ed1c61e1466b

Aslak

Great. Thanks!

2009/3/31 aslak hellesoy [email protected]: