Commit 804c255
Changed files (2)
lib
spec
unit
lib/money.rb
@@ -5,6 +5,14 @@ class Money
@amount = amount
end
+ def +(other)
+ plus(other)
+ end
+
+ def plus(other)
+ Money.new(@amount + other.amount)
+ end
+
def ==(other)
@amount == other.amount
end
spec/unit/money_spec.rb
@@ -15,4 +15,10 @@ describe Money do
end
end
end
+ context "when adding money" do
+ it "should return the new amount" do
+ result = Money.new(1.99) + Money.new(0.01)
+ result.should == Money.new(2.00)
+ end
+ end
end