Skip to content

Commit

Permalink
refactor test to turn cash with or without vat into a factory for the…
Browse files Browse the repository at this point in the history
… next tests
  • Loading branch information
julescopeland committed Jun 11, 2013
1 parent 0d860d3 commit b77395b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/test_cash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,17 @@ def test_cent_less_vat_without_vat_included
rs = Cash.new(120)
assert_equal rs.cents_less_vat, rs.cents
end

# factories
def cash_with_vat
Cash.new(100, :vat_included => :true)
end
def cash_without_vat
Cash.new(100, :vat_included => :false)
end

def test_mixed_vat_values
with_vat = ->{ Cash.new(100, :vat_included => :true) }.call
without_vat = ->{ Cash.new(100, :vat_included => :false) }.call
addition = with_vat + without_vat
addition = cash_with_vat + cash_without_vat
refute addition.vat_included?, 'vat seems to be included'
assert addition.vat_mixed?, 'vat should be mixed'
end
Expand Down

0 comments on commit b77395b

Please sign in to comment.