-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
48 lines (35 loc) · 1.02 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require "bundler/gem_tasks"
require 'rspec/core'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
describe 'Run Vinterior Test'
task :run do
project_root = File.dirname(File.absolute_path(__FILE__))
Dir.glob(project_root + '/lib/*') { |file| require file }
promo_rules = []
promo_rules << PromoRule.discount_rule(60, 10)
promo_rules << PromoRule.multi_discount_rule('001', 2, 8.50)
item1 = Product.new('001', 'Very Cheap Chair', 9.25)
item2 = Product.new('002', 'Little Table', 45.00)
item3 = Product.new('003', 'Funky Light', 19.95)
puts "scanning items 1,2,3"
co = Checkout.new(promo_rules)
co.scan(item1)
co.scan(item2)
co.scan(item3)
puts "Cost: #{co.total}"
puts "scanning items 1,3,1"
co = Checkout.new(promo_rules)
co.scan(item1)
co.scan(item3)
co.scan(item1)
puts "Cost: #{co.total}"
puts "scanning items 1,2,1,3"
co = Checkout.new(promo_rules)
co.scan(item1)
co.scan(item2)
co.scan(item1)
co.scan(item3)
puts "Cost: #{co.total}"
end