Skip to content

Instantly share code, notes, and snippets.

@ro-fdm
Created July 1, 2015 18:35
Show Gist options
  • Save ro-fdm/6d7a1b1cd9a7fd24d4d5 to your computer and use it in GitHub Desktop.
Save ro-fdm/6d7a1b1cd9a7fd24d4d5 to your computer and use it in GitHub Desktop.
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