If allow is not defined, it means that RSpec::Mocks::ExampleMethods hasn’t
been included in that context. I believe the fix would be:

World(RSpec::Mocks::ExampleMethods)

…but I haven’t written a cucumber hook in a long time.

One general question: why are you trying to unstub a method in an After
hook? The lifecycle used by rspec-mocks is per example (i.e. per scenario
in a cucumber context), assuming you’ve set it up correctly, so all stubs
will be removed after each scenario anyway.

HTH,
Myron
​

On Mon, Jul 27, 2015 at 8:51 AM, Grant Birchmeier <[email protected]
> wrote:

> In my cucumber hooks file, I had this code under RSpec 2:
>
> After do
>   begin
>     Challenge.unstub(:current)
>   rescue RSpec::Mocks::MockExpectationError
>   end
> end
>
>
> After upgrading to RSpec 3, I get a deprecation warning:
>
> DEPRECATION: Using unstub from rspec-mocks' old :should syntax without
> explicitly enabling the syntax is deprecated. Use
> allow(...).to_receive(...).and_call_original or explicitly enable :should
> instead. Called from /Users/grant/xx/features/support/hooks.rb:37:in block
> in <top (required)>.
>
>
> So I followed that, changing the offending line instead to:
>
> allow(Challenge).to receive(:current).and_call_original
>
>
> But now I get:
>
> undefined method allow for #<Cucumber::Rails::World:0x007facbed9f1d0>
> (NoMethodError)
>
>
> I've tried adding "include RSpec::Matchers" a few different ways, but it
> doesn't change anything.
>
> I'm kind of stuck.  Can anyone show me the way?
>
> -Grant
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/1dbbcdc2-d996-4d8a-b03f-5a8f6b1073a4%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/1dbbcdc2-d996-4d8a-b03f-5a8f6b1073a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CADUxQms-cRxQ-ZxoMBc90ZsLt8M5xOewG%3D-ry4Gj-ZLrSbU2%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to