Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rewinfrey/9542054 to your computer and use it in GitHub Desktop.
Save rewinfrey/9542054 to your computer and use it in GitHub Desktop.
A mock example to illustrate the difference between mocks and dummies
describe AmazonDrone do
it "collects order inventory from warehouse" do
warehouse = double(:warehouse)
order = double(:order) # dummy
inventory = double(:inventory) # dummy
# set expectations on behavior of warehouse "mock"
warehouse.should_receive(:fill_inventory).with(order).and_return(inventory)
drone = AmazonDrone.new(warehouse)
drone.collect_order_inventory(order)
drone.inventory.should_not be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment