btakita / rr

RR (Double Ruby) is a test double framework that features a rich selection of double techniques and a terse syntax.
http://github.com/rr/rr
MIT License
501 stars 58 forks source link

Spy verifies receipt of an attr assignment call #54

Open josephholsten opened 13 years ago

josephholsten commented 13 years ago
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 commented 13 years ago

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 commented 11 years ago

I can confirm this is still an issue.