diff --git a/spec/item_spec.rb b/spec/item_spec.rb index 4dfde22..139e4d1 100644 --- a/spec/item_spec.rb +++ b/spec/item_spec.rb @@ -2,7 +2,7 @@ require "./lib/item" module FakeTaxRates - def self.tax_rate_for_good name + def self.tax_rate_for_good(name) 0.1 end end @@ -10,37 +10,37 @@ def self.tax_rate_for_good name Item = ShoppingCart::Item describe Item do - describe "#tax returns amount of tax for the good:" do + describe "#tax returns amount of tax for the item:" do it "10% for item" do - good = Item.new 1, "item", 10.0, tax_rates: FakeTaxRates - expect(good.tax).to eq 1 + item = Item.new 1, "item", 10, tax_rates: FakeTaxRates + expect(item.tax).to eq 1 end it "double for 2 items" do - good = Item.new 2, "item", 10, tax_rates: FakeTaxRates - expect(good.tax).to eq 2 + item = Item.new 2, "item", 10, tax_rates: FakeTaxRates + expect(item.tax).to eq 2 end it "rounded up to the nearest 0.05" do - good = Item.new 1, "item", 47.30, tax_rates: FakeTaxRates - expect(good.tax).to eq 4.75 + item = Item.new 1, "item", 47.30, tax_rates: FakeTaxRates + expect(item.tax).to eq 4.75 end end - describe "#total returns unit_price + tax, multiplied by quantity" do + describe "#total returns total cost of items, including tax:" do it "one item" do - good = Item.new 1, "item", 10.0, tax_rates: FakeTaxRates - expect(good.total).to eq 11 + item = Item.new 1, "item", 10, tax_rates: FakeTaxRates + expect(item.total).to eq 11 end it "two items" do - good = Item.new 2, "item", 10.0, tax_rates: FakeTaxRates - expect(good.total).to eq 22 + item = Item.new 2, "item", 10.0, tax_rates: FakeTaxRates + expect(item.total).to eq 22 end end it "#to_s returns quantity, name and total" do - good = Item.new 2, "item", 10.0, tax_rates: FakeTaxRates - expect(good.to_s).to eq "2, item, 22.00" + item = Item.new 2, "item", 10, tax_rates: FakeTaxRates + expect(item.to_s).to eq "2, item, 22.00" end end