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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71093e95d940db3009c9aae19969442a?d=identicon&s=25 Josh Chisholm (Guest)
on 2009-03-31 12:08
(Received via mailing list)
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/27a6f718...

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
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-03-31 12:52
(Received via mailing list)
On Tue, Mar 31, 2009 at 11:34 AM, Josh Chisholm
<joshuachisholm@gmail.com>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/27a6f718...
>

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/6c...

Aslak
71093e95d940db3009c9aae19969442a?d=identicon&s=25 Josh Chisholm (Guest)
on 2009-03-31 13:12
(Received via mailing list)
Great. Thanks!

2009/3/31 aslak hellesoy <aslak.hellesoy@gmail.com>:
This topic is locked and can not be replied to.