[Rspec-devel] mock.send defect

David Chelimsky dchelimsky at gmail.com
Sun Apr 30 10:11:49 EDT 2006


Works for me.

On 4/30/06, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> RSpec mocks are implemented using method_missing.
> However, if you send a message to a mock that _is_ defined (i.e. all
> methods inherited from Object), method_missing will not be called.
> This is the case for send, plus a lot of other methods.
>
> I think we need to undefine all inherited methods.
>
> Thoughts?
>
> On 4/30/06, Dean Mao <deanmao at gmail.com> wrote:
> > 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
> > _______________________________________________
> > Rspec-devel mailing list
> > Rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
> >
> >
>
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>



More information about the Rspec-devel mailing list