Sorry about that. I don't always jump on things like that, but this one was 
bugging me and I had the time so I just did it. That doesn't always happen :) I 
look forward to your future contributions.

Cheers,
David


-- 
David Chelimsky
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Sunday, April 15, 2012 at 9:30 PM, Bas Vodde wrote:

> 
> Hiya,
> 
> Kewl, thanks!
> 
> (To be honest, I was a bit disapointed as I was thinking of doing it myself 
> and sending it to you :P)
> 
> Anyways, much appreciated!
> 
> Bas
> 
> On 16-Apr-2012, at 10:14 AM, David Chelimsky wrote:
> 
> > Actually I just went ahead and fixed it sans-bug report: 
> > https://github.com/rspec/rspec-mocks/commit/fb9c76c2e40b4b25f4dcc5de95f8c60319b6d9c1.
> >  It'll be fixed in the next release (2.10).
> > 
> > Cheers,
> > David
> > 
> > -- 
> > David Chelimsky
> > Sent with Sparrow
> > 
> > On Sunday, April 15, 2012 at 4:48 PM, David Chelimsky wrote:
> > 
> > > On Sunday, April 15, 2012 at 1:32 AM, Bas Vodde wrote:
> > > > 
> > > > Hiya all,
> > > > 
> > > > I've got a quick question related to RSpec. I was test-driving some 
> > > > code and ended up in an endless loop. I was surprised by this, but 
> > > > traced it down to the mock not failing on additional calls but only in 
> > > > the end. Let me explain.
> > > > 
> > > > I was writing code like this:
> > > > 
> > > > subject.wrapper.should_receive(:window_list).exactly(4).times.and_return
> > > >  {
> > > > counter = counter + 1
> > > > counter >= 4 ? [ "new window" ] : []
> > > > }
> > > > 
> > > > The idea was that it would call the code-block 4 times exactly and then 
> > > > return a new value (and thus stop calling it). As the code to implement 
> > > > wasn't there yet, it led to a recursive call. I had expected RSpec to 
> > > > stop after 4 calls though, as I had instructed the mock that I expected 
> > > > exactly 4 calls.
> > > > 
> > > > I added a new test in RSpec itself in precision_counts_spec.rb:
> > > > 
> > > > it "fails when a method is called more than n times, but fails within 
> > > > the method call" do
> > > > @mock.should_receive(:random_call).exactly(1).times
> > > > lambda do
> > > > @mock.random_call
> > > > @mock.random_call
> > > > end.should raise_error(RSpec::Mocks::MockExpectationError)
> > > > end
> > > > 
> > > > which failed :( (or it failed to fail and therefore failed!)
> > > > 
> > > > It would be nice if it would fail. Is there any reason for not failing 
> > > > already at this point in time?
> > > > 
> > > > (I'm using RSpec 2.6-0. I quickly browsed the latest and didn't see 
> > > > this changed)
> > > > 
> > > > Thanks,
> > > > 
> > > > Bas
> > > There is no philosophical reason for this to happen, and there are other 
> > > types of failures that do fail-fast (e.g. 
> > > obj.should_receive(:bar).with(1,2) fails immediately if it receives :bar 
> > > with any other args).
> > > 
> > > Please submit this to https://github.com/rspec/rspec-mocks/issues and 
> > > I'll start looking into a fix.
> > > 
> > > Cheers,
> > > David
> > > 
> > 
> > 
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@rubyforge.org (mailto:rspec-users@rubyforge.org)
> > http://rubyforge.org/mailman/listinfo/rspec-users
> > 
> 
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org (mailto:rspec-users@rubyforge.org)
> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> 


_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to