summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/money.rb6
-rw-r--r--spec/unit/money_spec.rb5
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/money.rb b/lib/money.rb
index 11394e6..0a32f50 100644
--- a/lib/money.rb
+++ b/lib/money.rb
@@ -6,11 +6,11 @@ class Money
end
def +(other)
- plus(other)
+ Money.new(@amount + other.amount)
end
- def plus(other)
- Money.new(@amount + other.amount)
+ def -(other)
+ Money.new(@amount - other.amount)
end
def ==(other)
diff --git a/spec/unit/money_spec.rb b/spec/unit/money_spec.rb
index 9716db2..2934a67 100644
--- a/spec/unit/money_spec.rb
+++ b/spec/unit/money_spec.rb
@@ -21,4 +21,9 @@ describe Money do
result.should == Money.new(2.00)
end
end
+ context "when subtracting money" do
+ it "should return the correct amount" do
+ (Money.new(1.99) - Money.new(0.99)).should == Money.new(1.00)
+ end
+ end
end