Commit 804c255

mo khan <mo@mokhan.ca>
2013-04-29 23:08:24
add simple money together
1 parent 6de6101
Changed files (2)
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