With its
you can switch the subject of an example to a method value of the current subject:
describe Array do
its(:length) { should == 0 }
end
stub_chain
is the tie to go along with should_receive_chain's tux:
object.stub_chain(:first, :second, :third).and_return(:this)
You can restore the original implementation of stubbed methods with unstub
:
object.stub(:foo => 'bar')
# ...
object.unstub(:foo)
In recent RSpecs double
is the preferred way to create a mock object (stub
and mock
are aliases):
admin = double('admin user').as_null_object
Posted by Henning Koch to makandra dev (2010-09-16 12:49)