master
 1require "spec_helper"
 2
 3describe Money do
 4  context "when comparing money" do
 5    context "when the amount is the same" do
 6      it "should return true" do
 7        Money.new(1.00).should == Money.new(1.00)
 8        Money.new(10.00).should eq(Money.new(10.00))
 9      end
10    end
11    context "when the amount is different" do
12      it "should return false" do
13        Money.new(1.00).should_not == Money.new(10.00)
14        Money.new(10.00).should_not eq(Money.new(1.00))
15      end
16    end
17  end
18  context "when adding money" do
19    it "should return the new amount" do
20      result = Money.new(1.99) + Money.new(0.01)
21      result.should == Money.new(2.00)
22    end
23  end
24  context "when subtracting money" do
25    it "should return the correct amount" do
26      (Money.new(1.99) - Money.new(0.99)).should == Money.new(1.00)
27    end
28  end
29end