forked from rspec/rspec-mocks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Feature: stub_chain | ||
|
||
Scenario: stub a chain of methods | ||
Given a file named "stub_chain_spec.rb" with: | ||
""" | ||
describe "stubbing a chain of methods" do | ||
subject { Object.new } | ||
context "given symbols as methods" do | ||
it "returns the correct value" do | ||
subject.stub_chain(:one, :two, :three).and_return(:four) | ||
subject.one.two.three.should eql(:four) | ||
end | ||
end | ||
context "given a string of methods separated by dots" do | ||
it "returns the correct value" do | ||
subject.stub_chain("one.two.three").and_return(:four) | ||
subject.one.two.three.should eql(:four) | ||
end | ||
end | ||
end | ||
""" | ||
When I run "rspec stub_chain_spec.rb" | ||
Then the output should contain "2 examples, 0 failures" |