I''m seeing some odd behavior around the should_receive() when given a block combined with some cardinality. For example, with the following... my_mock.should_receive(:foo).twice do |i| puts i end ... the spec passes but i never gets puts''ed. With the following... my_mock.should_receive(:foo) do |i| puts i end ... i gets puts''ed twice but the spec fails because it was only expecting one call to :foo. Micah Martin 8th Light, Inc. 8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070207/19e5c667/attachment-0001.html
On 2/7/07, Micah Martin <micah at 8thlight.com> wrote:> I''m seeing some odd behavior around the should_receive() when given a block > combined with some cardinality. > > For example, with the following... > > my_mock.should_receive(:foo).twice do |i| > puts i > endBlocks aren''t currently supported in any form besides: my_mock.should_receive(args) { } Since none of the other methods (#with, #once, #twice, etc) deal with a block, the block is never being invoked. Feel free to submit an RFE if you feel this should be supported. Cheers, David> > ... the spec passes but i never gets puts''ed. > > With the following... > > my_mock.should_receive(:foo) do |i| > puts i > end > > ... i gets puts''ed twice but the spec fails because it was only expecting > one call to :foo. > > > Micah Martin > 8th Light, Inc. > 8thlight.com > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Thanks David. That explains it. RFE submitted with specs: https://rubyforge.org/tracker/index.php? func=detail&aid=8484&group_id=797&atid=3152 Micah Martin 8th Light, Inc. 8thlight.com On Feb 7, 2007, at 11:45 AM, David Chelimsky wrote:> > Blocks aren''t currently supported in any form besides: > > my_mock.should_receive(args) { > } > > Since none of the other methods (#with, #once, #twice, etc) deal with > a block, the block is never being invoked. > > Feel free to submit an RFE if you feel this should be supported. > > Cheers, > David-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070207/4e8ae9a4/attachment.html
On 2/7/07, Micah Martin <micah at 8thlight.com> wrote:> Thanks David. That explains it. > > RFE submitted with specs: > https://rubyforge.org/tracker/index.php?func=detail&aid=8484&group_id=797&atid=3152Thanks. I''m already on this and will commit the fix tonight. Cheers> > Micah Martin > 8th Light, Inc. > 8thlight.com > > On Feb 7, 2007, at 11:45 AM, David Chelimsky wrote: > > Blocks aren''t currently supported in any form besides: > > my_mock.should_receive(args) { > } > > Since none of the other methods (#with, #once, #twice, etc) deal with > a block, the block is never being invoked. > > Feel free to submit an RFE if you feel this should be supported. > > Cheers, > David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >