Created
October 22, 2012 14:50
-
-
Save erkattak/3931850 to your computer and use it in GitHub Desktop.
BigDecimal Float comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe CashTransaction do | |
context "when transaction is not a refund" do | |
subject { CashTransaction.new refund: false } | |
context "when an amount is positive" do | |
before(:each) do | |
subject.amount = 19.90 | |
subject.save | |
end | |
its(:amount) { should eq 19.90 } | |
end | |
context "whent the amount is negative" do | |
before(:each) do | |
subject.amount = -21.04 | |
subject.save | |
end | |
its(:amount) { should eq 21.04 } | |
end | |
end | |
context "when transaction is a refund" do | |
subject { CashTransaction.new refund: true } | |
context "when an amount is positive" do | |
before(:each) do | |
subject.amount = 100.00 | |
subject.save | |
end | |
its(:amount) { should eq 100.00 } | |
end | |
context "whent the amount is negative" do | |
before(:each) do | |
subject.amount = -100.00 | |
subject.save | |
end | |
its(:amount) { should eq 100.00 } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment