Created
June 7, 2010 12:38
-
-
Save benbc/428624 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# one of these examples fails, depending on the call order in #test | |
describe "it" do | |
before { @subject = mock } | |
before { @subject.stub!(:it) } | |
it "does 1" do | |
@subject.should_receive(:it). | |
and_return { |block| block.call.should ==1 } | |
test(@subject) | |
end | |
it "does 2" do | |
@subject.should_receive(:it). | |
and_return { |block| block.call.should ==2 } | |
test(@subject) | |
end | |
end | |
def test subject | |
subject.it { 1 } | |
subject.it { 2 } | |
end |
This file contains hidden or 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
# this passes | |
describe "it" do | |
before { @subject = mock } | |
it "does 1" do | |
@subject.should_receive(:it). | |
and_return { |block| block.call.should ==1 } | |
test(@subject) | |
end | |
end | |
def test subject | |
subject.it { 1 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment