Search code examples
ruby-on-railstestingrspecrspec-rails

RSpec: Using view.should_receive with subject


Any ideas why this works:

it {view.should_receive(:update_method)}

but this doesn't?:

subject { view }
it { should_receive(:update_method) }

Everything else being the same. I get this error:

Failure/Error: it {should_receive(:update_method) 
(#<RSpec::Core::ExampleGroup::Nested_1:0x7faf27602d58>).update_method
    expected: 1 time
    received: 0 times 

But I don't know what RSpec::Core::ExampleGroup::Nested.... is referring to. Any ideas?

Thanks in advance!


Solution

  • That's the second time this has come up in 24 hours. Something's in the air. See https://github.com/rspec/rspec-mocks/issues/148 for the explanation.