-
-
Save plagelao/813032 to your computer and use it in GitHub Desktop.
This file contains 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
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 |
This file contains 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
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