On Sunday, July 06, 2014 10:59:38 AM Xavier Shay wrote:
> On 6/07/2014 9:45 am, Arup Rakshit wrote:
> > On Sunday, July 06, 2014 09:23:06 AM Antonio Antillon wrote:
> >> Hi Arup,
> >> 
> >> try doing this in your foo_spec.rb
> >> 
> >> describe Foo do
> >> 
> >>    before { allow(Foo).to receive(:baz).and_return(20) }
> >>    
> >>    # all other lines as they are
> >> 
> >> end
> > 
> > Basically this example is a small part of my actual code. I generally
> > sometime don't want to call the original method, rather I stub it, the
> > way I set the example in my original post. Then from the example, I call
> > the method and expect it to show the same behavior the way I stubbed it.
> > 
> > In Rspec 3 it seems *stubbing* is not possible. *stubbing* and
> > *expectation* is merged in the same line of code, like below and it works
> > too :-
> This is what `allow` does. It is different from `expect`. Try it:
> 
> allow_any_instance_of(Foo).to receive(:baz).and_return(20)

Nice to know. Could you elaborate what is the diff between 
*expect_any_instance_of* and *allow_any_instance_of* ... Which one to use in 
what case... Example code may help also for better understanding.... 


-- 
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, 
if you write the code as cleverly as possible, you are, by definition, not 
smart enough to debug it.

--Brian Kernighan

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/20663067.tT6kujFS8M%40linux-wzza.site.
For more options, visit https://groups.google.com/d/optout.

Reply via email to