On Tue, Jul 23, 2013 at 8:57 AM, David Chelimsky <[email protected]>wrote:
> On Tue, Jul 23, 2013 at 8:43 AM, David Chelimsky <[email protected]>wrote: > >> On Tue, Jul 23, 2013 at 7:22 AM, George Mendoza <[email protected]>wrote: >> >>> Hello everybody, >>> >>> I'm trying to update my rspec extension gem ( >>> https://github.com/gsmendoza/verified_double) to the new expect syntax >>> of rspec-mocks. I guessed that I can do this by creating a thin wrapper >>> over the expect, receive, and allow methods of RSpec::Mocks::Syntax: >>> >>> # >>> https://github.com/gsmendoza/verified_double/blob/7-convert-from-should_receive-to-expect-syntax/lib/verified_double/rspec_mocks_syntax_overrides.rb >>> >>> module VerifiedDouble >>> module RSpecMocksSyntaxOverrides >>> def expect(*args) >>> VerifiedDouble.registry.current_double = args[0] >>> super(*args) >>> end >>> >>> def receive(*args) >>> >>> VerifiedDouble.registry.add_method_signature_with_current_double(args[0]) >>> super(*args).tap {|result| >>> result.extend(VerifiedDouble::CanRecordInteractions) } >>> end >>> end >>> end >>> >>> The test for overridden >>> expect<https://github.com/gsmendoza/verified_double/blob/7-convert-from-should_receive-to-expect-syntax/spec/verified_double/rspec_mocks_syntax_overrides_spec.rb> >>> method passes, >>> but the test for the receive method fails. If I rename my receive method to >>> something else like better_receive, then the test suite can pick it up. >>> >>> If you can point me where or how to integrate the >>> VerifiedDouble::RSpecMocksSyntaxOverrides module, that would be a big help >>> :) >>> >> >> I cloned the repo, checked out the branch, ran rspec and got the >> following error: >> >> undefined method `add_method_signature_with_current_double' for >> #<VerifiedDouble::RecordedMethodSignatureRegistry:0x007f9cdab73f58> >> >> Then I grepped through the code and I don't see >> any add_method_signature_with_current_double method, so the error seems >> legit to me. I might be missing something (like a `method_missing` designed >> to handle this) but maybe that helps point you in the right direction. >> >> HTH, >> David >> > > Just realized I ran that using rspec-2.13 :) > > Please disregard. > > As a general FYI, please include the failure message when asking for help > instead of just saying that it failed. Had I seen the error message was > different from mine I wouldn't have wasted your time or mine w/ my previous > response. > I think I found part of the problem: receive is defined by rspec-mocks when the configuration is eval'd and `enable_expect` is invoked: https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/syntax.rb#L87 That happens after all the requires, therefore verified-double's version of `receive` is defined _before_ rspec's version. You'll need a way to ensure verified-double's version gets defined after rspec's version. @myronmarston - any thoughts on the best way to do that ^^? That, plus I still don't see add_method_signature_with_current_double anywhere in the code, so that might still be a problem. HTH, David -- 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/CAKw-oWRAWT_Tw1GviXXvfP-spM7eRMzd1MPgZ%3D7yyzScD%3DsmOg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
