Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spy verifies receipt of an attr assignment call #54

Open
josephholsten opened this issue Apr 19, 2011 · 2 comments
Open

Spy verifies receipt of an attr assignment call #54

josephholsten opened this issue Apr 19, 2011 · 2 comments
Milestone

Comments

@josephholsten
Copy link

describe 'Spy' do
  subject { stub!.subject }
  describe "with an attr_writer" do
    before { stub(subject).attribute=(anything) }
    context "after setting the attr" do
      before { subject.attribute = :value }
      it("verifies receipt of the call") { should have_received.attribute=(:value) }
      it("verifies receipt of the call via method_missing hack") { should have_received.method_missing(:attribute=, :value) }
    end
  end
end
@DouglasMeyer
Copy link

Unless you run the test, I'm not sure if the problem is obvious. Essentially

should have_recieved.attribute(:value)

works but

should have_recieved.attribute=(:value)

doesn't work.

It looks like RR::SpyVerificationProxy.method_missing isn't returning the new RR::SpyVerification. This looks like a ruby issue as a = b = 1 will set a to 1 and not the result of b= (hope that makes sense).
I don't think this is something that can be fixed in a simple patch and may require something more drastic like a new api for spies.

In the mean-time you could manually verify with something like

RR::SpyVerification.new(subject, :attribute=, :value).call

@mcmire
Copy link
Collaborator

mcmire commented Mar 15, 2013

I can confirm this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants