Created
July 1, 2015 18:35
-
-
Save ro-fdm/6d7a1b1cd9a7fd24d4d5 to your computer and use it in GitHub Desktop.
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
require "minitest/autorun" | |
require_relative 'checkout.rb' | |
describe Checkout do | |
before do | |
@checkout = Checkout.new(nil) | |
end | |
# Items: AM,AC,AM,AM,CA | |
# Precio total esperado: 22.45€ | |
describe "when scan three am" do | |
it "must apply 2x1 in am" do | |
["AM", "AC", "AM", "AM", "CA"].each do |item| | |
@checkout.scan(item) | |
end | |
@checkout.total.must_equal 22.45 | |
end | |
end | |
# Items: AM,AM | |
# Precio total esperado: 3.11€ | |
describe "when scan two am" do | |
it "must apply 2x1 in am" do | |
["AM", "AM"].each do |item| | |
@checkout.scan(item) | |
end | |
@checkout.total.must_equal 3.11 | |
end | |
end | |
# Items: AC,AC,AM,AC | |
# Precio total esperado: 16.61€ | |
describe "when scan three ac" do | |
it "must apply discount in ac" do | |
["AC", "AC", "AM", "AC"].each do |item| | |
@checkout.scan(item) | |
end | |
@checkout.total.must_equal 16.61 | |
end | |
end | |
# Items: AC,AC,AM,AM,AC,CA,CA | |
# Precio total esperado: 16.61€ | |
describe "when scan three ac, two am" do | |
it "must apply both discounts" do | |
["AC", "AC", "AM", "AM", "AC", "CA", "CA"].each do |item| | |
@checkout.scan(item) | |
end | |
@checkout.total.must_equal 39.07 | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment