RSpec stub_chain

bdd

Sat Jul 04 12:55:01 -0700 2009

class Widget
  def foo
    bar.baz.fourty_two
  end
end

describe Widget
  it "runs a method chain" do
    widget = Widget.new
    widget.stub_chain(:bar, :baz, :fourty_two => 42)
    widget.foo.should == 42
  end
end

You need the latest RSpec (1.2.7 as of this writing) to get stub_chain.