Skip to content

Instantly share code, notes, and snippets.

@plagelao
Forked from AlfredoCasado/gist:776187
Created February 6, 2011 02:04
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 plagelao/813032 to your computer and use it in GitHub Desktop.
Save plagelao/813032 to your computer and use it in GitHub Desktop.
describe Order do
let(:product){stub(:product)}
let(:payment_gateway){stub(:payment_gateway)}
let(:order){Order.new(payment_gateway)}
it "confirm the order if the client has funds" do
product.stub(:price).and_return(50)
payment_gateway.stub(:user_has_funds).with(50).and_return(true)
order.buy(product).should be_true
end
end
describe Order do
let(:product){stub(:product)}
let(:payment_gateway){mock(:payment_gateway)}
let(:order){Order.new(payment_gateway)}
it "the payment gateway is called with the order price" do
product.stub(:price).and_return(50)
payment_gateway.should_receive(:user_has_funds).with(50)
order.buy(product)
end
it "confirm the order if the client has funds" do
payment_gateway.stub(:user_has_funds).and_return(true)
order.buy(product).should be_true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment