Module | Spec::Mocks::Methods |
In: |
lib/spec/mocks/methods.rb
|
Supports stubbing a chain of methods. Each argument represents a method name to stub, and each one returns a proxy object that can accept more stubs, until the last, which returns whatever is passed to +and_return_.
# with this in an example ... article = double('article') Article.stub_chain(:authored_by, :published, :recent).and_return([article]) # then this will return an Array with the article double in it: Article.authored_by(params[:author_id]).published.recent