Created
December 31, 2010 16:06
-
-
Save bgswan/761110 to your computer and use it in GitHub Desktop.
Example of a mock test and the same test with a spy
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
# Checking an interaction with a mock | |
it "should notify bidders in a mocky way" do | |
bidder = mock( :bidder ) | |
bidder.should_receive( :bid_changed ).with( '10.00' ) | |
auctioneer = Auctioneer.new | |
auctioneer.add_bidder( bidder ) | |
auctioneer.accept_bid( '10.00' ) | |
end | |
# Checking an interaction with a spy | |
it "should notify bidders" do | |
bidder = stub( :bidder ).as_null_object | |
auctioneer = Auctioneer.new | |
auctioneer.add_bidder( bidder ) | |
auctioneer.accept_bid( '10.00' ) | |
assert bidder.received_message?( :bid_changed, '10.00' ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment