Skip to content

Commit

Permalink
* Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledestin committed Aug 17, 2014
1 parent 86bc449 commit 78fcfd0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion spec/numeric_money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
expect(1.1111.to_formatted_s(:money)).to eq "1.11"
end

it "also works for integers" do
it "when it's an integer" do
expect(10.to_formatted_s(:money)).to eq "10.00"
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/receipt_printer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "open3"

def run input, expected_output
def run(input, expected_output)
output, = Open3.capture2e("./receipt_printer", :stdin_data => input)
expect(output).to eq expected_output
end
Expand All @@ -21,7 +21,7 @@ def run input, expected_output
Sales Taxes: 1.50
Total: 29.83
EOF
run(input, expected_output)
run input, expected_output
end

it "input 2" do
Expand All @@ -37,7 +37,7 @@ def run input, expected_output
Sales Taxes: 7.65
Total: 65.15
EOF
run(input, expected_output)
run input, expected_output
end

it "input 3" do
Expand All @@ -57,6 +57,6 @@ def run input, expected_output
Sales Taxes: 6.70
Total: 74.68
EOF
run(input, expected_output)
run input, expected_output
end
end
18 changes: 9 additions & 9 deletions spec/receipt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

describe ShoppingCart::Receipt do
[:total, :tax].each do |method|
describe "##{method} returns sum of all goods #{method}" do
it "for one good" do
goods = [ShoppingCart::Item.new(1, "book", 12.49)]
expect(ShoppingCart::Receipt.new(goods).send(method)).to eq \
goods.map(&method).inject(:+)
describe "##{method} returns sum of all items' ##{method}:" do
it "for one item" do
items = [ShoppingCart::Item.new(1, "book", 12.49)]
expect(ShoppingCart::Receipt.new(items).send(method)).to eq \
items.map(&method).inject(:+)
end

it "for multiple goods" do
goods = [ShoppingCart::Item.new(1, "book", 12.49),
it "for multiple items" do
items = [ShoppingCart::Item.new(1, "book", 12.49),
ShoppingCart::Item.new(1, "chocolate bar", 0.85)]
expect(ShoppingCart::Receipt.new(goods).send(method)).to eq \
goods.map(&method).inject(:+)
expect(ShoppingCart::Receipt.new(items).send(method)).to eq \
items.map(&method).inject(:+)
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions spec/tax_rates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ def tax_rate_for_good name
end

describe TaxRates do
it "self.tax_rate_for_good works" do
expect(TaxRates.tax_rate_for_good("book")).to be_zero
end

describe "#tax_rate_for_good returns tax:" do
context "zero" do
it "for books" do
Expand Down

0 comments on commit 78fcfd0

Please sign in to comment.