Reputation: 660
Let's say that I have a class called MyClass, basically I want to do something like this:
class MyClass def initialize(a) do_stuff a, 4, 11 end def do_stuff(a,b,c) # ... end end # rspec below MyClass.any_instance.should_receive(:do_stuff).with_the_values(10, anything, anything) MyClass.new 10
Basically, I want to check that initialize will call on, and pass the correct value to do_stuff
.
Upvotes: 0
Views: 40
Reputation: 230286
I think you should test if your class behaves correctly or not instead of watching who passes what to whom.
I guess, the do_stuff
method is supposed to produce a side-effect of some sort. If so, then check if this side-effect is the one you expect. This way you're free to change actual implementation of your class without needing to rewrite your specs every time.
Upvotes: 2