diff --git a/lib/fbe/award.rb b/lib/fbe/award.rb index e8136218..7fd651b1 100644 --- a/lib/fbe/award.rb +++ b/lib/fbe/award.rb @@ -378,7 +378,7 @@ def line(value, text) # bill.line(42.5, "for answer") # bill.points #=> 43 def points - @lines.sum { |l| whole(l[:v]) } + whole(@lines.sum { |l| l[:v] }) end # Generates a human-readable summary of the bill. diff --git a/test/fbe/test_award.rb b/test/fbe/test_award.rb index a6174ad0..10f78c49 100644 --- a/test/fbe/test_award.rb +++ b/test/fbe/test_award.rb @@ -140,6 +140,13 @@ def test_lines_add_up_to_the_total assert_equal("You've earned +20 points for this: +12 as a basis; +8 for comments. ", g) end + def test_rounds_the_sum_once + bill = Fbe::Award::Bill.new + bill.line(0.5, 'first') + bill.line(0.5, 'second') + assert_equal(1, bill.points) + end + def test_shorten_when_one_number g = Fbe::Award.new('(award (give 23 "for love"))').bill.greeting assert_equal('You\'ve earned +23 points. ', g, g)