[Rspec-devel] mock.send defect

Dean Mao deanmao at gmail.com
Sun Apr 30 03:25:08 EDT 2006


I was asked to post this on the list.  This is catch23 on freenode.  Below
is the context of the discussion, along with the test case used to produce
the results.

(03:05:06) *catch23:* so i'm trying to mock some of the objects in the
jabber library, but some of the classes there override send
(03:06:42) *catch23:* and so i'm thinking it's not possible to do a
.should.receive(:send) type of thing... when the mock.send happens, it
thinks it's actually trying to perform a method call
(03:07:18) *srbaker:* oh wow
(03:07:26) *srbaker:* that's... awesome.
(03:07:48) *catch23:* i guess nobody has encountered this eh? hehe
(03:16:09) *catch23:* I'm showing 2 examples, one where the message is
"sendb" and one where the message is "send"
(03:16:25) *catch23:* the example with "sendb" works, the message with
"send" fails
(03:17:20) *catch23:* do those test cases look okay?
(03:19:02) *srbaker:* that looks great. put that on the list

context "testing send" do
  specify "should be able to mock test" do
    test_mock = mock("test")
    test_mock.should.receive(:sendb) {puts "success"}
    test_mock.sendb
  end
end

----> this is okay

context "testing send" do
  specify "should be able to mock test" do
    test_mock = mock("test")
    test_mock.should.receive(:send) {puts "success"}
    test_mock.send
  end
end

----> this fails
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060430/a6fd2f05/attachment.htm 


More information about the Rspec-devel mailing list