Skip to content

Instantly share code, notes, and snippets.

@lazyatom
Created December 13, 2010 10:15
Show Gist options
  • Save lazyatom/738863 to your computer and use it in GitHub Desktop.
Save lazyatom/738863 to your computer and use it in GitHub Desktop.
Hmm.
context "a thing" do
setup do
@mailer = TestMailer.new
@thing = Thing.new(@mailer)
end
should "send an email when poked" do
@mailer.expects(:send_email)
@thing.poke
end
should "increase the poke count" do
previous_poke_count = @thing.poke_count
@thing.poke
assert_equal previous_poke_count + 1, @thing.poke_count
end
should "be marked as poked" do
@thing.poke
assert @thing.poked?
end
end
# vs
context "a thing" do
setup do
@mailer = TestMailer.new
@thing = Thing.new(@mailer)
end
doing { @thing.poke }
expect "an email to be sent" { @mailer.expects(:send_email)}
should_change { @thing.poke_count }
should "be marked as poked" { assert @thing.poked? }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment