[rspec-users] i cannot seem to use at_least

14 views
Skip to first unread message

deepak kannan

unread,
Sep 26, 2012, 8:16:06 AM9/26/12
to rspec...@rubyforge.org
hi,

Problem is that i want to test chained method calls. Where the method chain is optional
But if the method chain is called then certain assertions apply on the method chain itself

The object may or may not call a method. 
But if it does call the method then it has to call another method on it (ie. method chain) with certain arguments
I wrote a comment explaining my actual usecase at https://github.com/rspec/rspec-mocks/issues/133#issuecomment-8886264

kind-of obfuscated and simplified code example is at https://gist.github.com/3788035

code snippet:
mock = mock('Monitor')
mock.should_receive(:ping).with('DS1').and_return(stub.as_null_object)
devops.should_receive(:monitor).and_return(proxy)

Ben Lovell

unread,
Sep 26, 2012, 8:35:02 AM9/26/12
to rspec-users
Hi
Did you read the discussion from the issue? 


It makes a strong case as to why at_least(0) makes no sense.

Cheers,
Ben

deepak

unread,
Sep 26, 2012, 11:29:29 PM9/26/12
to rs...@googlegroups.com, rspec-users
@ben i did read the discussion for issue#133. 
But i did not get the argument that at_least(0) should be a stub. @myronmarston comment at the end, cleared that up for me

After reading it again, i came up with https://gist.github.com/3792506
am a rspec noob so please forgive the bad example
If it is not too much of a problem, can someone post some code on how to solve the issue
Reply all
Reply to author
Forward
0 new messages