> > 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....
> in your words, allow_any = stubbing, expect_any = expectation
>
> This is described here:
> https://relishapp.com/rspec/rspec-mocks/v/3-0/docs/working-with-legacy-code/
> any-instance (follow the links to "Allow" and "Expect")
>
> Cheers,
> Xavier
That's helpful really. I am going through the Relish doco page by page. So
still couldn't reach to the page you linked. :-) But I got it clear. It seems,
I can change these 2 methods interchangeably. No difference in their use. Both
will run happily :-
RSpec.describe "allow_any_instance_of" do
context "with receive_messages" do
it "stubs multiple methods" do
allow_any_instance_of(Object).to receive_messages(:foo => 'foo', :bar =>
'bar')
o = Object.new
expect(o.foo).to eq('foo')
expect(o.bar).to eq('bar')
end
end
end
and
RSpec.describe "allow_any_instance_of" do
context "with receive_messages" do
it "stubs multiple methods" do
expect_any_instance_of(Object).to receive_messages(:foo => 'foo', :bar
=> 'bar')
o = Object.new
expect(o.foo).to eq('foo')
expect(o.bar).to eq('bar')
end
end
end
Only difference remains on people, who like allow_*, will use this, who don't
like it, will use expect_* ... :-)
--
================
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/1987352.0Z8Q82caqM%40linux-wzza.site.
For more options, visit https://groups.google.com/d/optout.