Recent RSpec features you might not know about

Updated . Posted . Visible to the public.

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
Henning Koch
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-09-16 12:49)