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 |
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
# common use of mocks in a Rails app | |
it "updates the requested book" do | |
mock_book = mock(:book) | |
Book.should_receive(:find).with("37").and_return(mock_book) | |
mock_book.should_receive(:update_attributes).with({:these => 'params'}) | |
put :update, :id => "37", :book => {:these => 'params'} | |
end | |
# without mocks a more readable, less brittle test | |
it "updates the requested book" do |
NewerOlder