Skip to content

Instantly share code, notes, and snippets.

@erkattak
Created October 22, 2012 14:50
Show Gist options
  • Save erkattak/3931850 to your computer and use it in GitHub Desktop.
Save erkattak/3931850 to your computer and use it in GitHub Desktop.
BigDecimal Float comparison
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