Skip to content

Instantly share code, notes, and snippets.

@benbc
Created June 7, 2010 12:38
Show Gist options
  • Save benbc/428624 to your computer and use it in GitHub Desktop.
Save benbc/428624 to your computer and use it in GitHub Desktop.
# 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 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