[rspec-users] 'Expected NoMethodError, got NameError'
dchelimsky at gmail.com
Mon Jan 4 16:00:29 EST 2010
On Mon, Jan 4, 2010 at 2:57 PM, Andrew Premdas <apremdas at gmail.com> wrote:
> 2009/12/30 Paul Hinze <paul.t.hinze at gmail.com>
> Given this simple cucumber feature (related to another rspec bug I am
>> working on):
>> I'm fighting with this error messages that _only_ shows up in certain
>> situations that I can't quite pin down (rake features breaks, individual
>> cucumber run works, rake with debugger beforehand works...)
>> > expected NoMethodError, got #<NameError: undefined local variable or
>> method `nap' for Time:Class
>> > ./features/step_definitions/stubs_dont_leak_steps.rb:10:in `/^nap time
>> should not be defined$/'
>> > features/either/stubs_dont_leak.feature:11:in `Then nap time should not
>> be defined'
>> I've tracked it down to this line:
> This method is really unpleasant, perhaps some standard refactorings to
> remove the complex conditional conditions and remove the nested if's would
> be useful first of all.
Agreed. Patches welcome!
> def message_received(sym, *args, &block)
>> expectation = find_matching_expectation(sym, *args)
>> stub = find_matching_method_stub(sym, *args)
>> if (stub && expectation && expectation.called_max_times?) || (stub &&
>> if expectation = find_almost_matching_expectation(sym, *args)
>> expectation.advise(args, block) unless
>> stub.invoke(*args, &block)
>> elsif expectation
>> expectation.invoke(*args, &block)
>> elsif expectation = find_almost_matching_expectation(sym, *args)
>> expectation.advise(args, block) if null_object? unless
>> raise_unexpected_message_args_error(expectation, *args) unless
>> (has_negative_expectation?(sym) or null_object?)
>> --> @target.__send__ :method_missing, sym, *args, &block
>> My question is this... why do we fall back to method_missing here rather
>> than a simple 'send' to the target? I figure there is likely a reason,
>> so if someone could help me understand I'll happily open up my
>> expectation to should_raise(NameError) and move along. :)
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users