Paypal::Payment::Common::Amount should properly equate to Numerics
nbibler opened this issue · comments
I just wanted to point out an unexpected result that I came across while upgrading:
In an upgrade from 0.2 to 0.4, one spec failure that occurred was that a Paypal::Payment::Request.new(amount: 12.34).amount.should == 12.34
. While this is not exactly the spec, it's actual spec failed with the following error:
Failure/Error: its(:amount) { should == 12.34 }
expected: 12.34
got: #<Paypal::Payment::Common::Amount:0x007fc5bc5a4a40 @total=12.34, @item=0, @fee=0, @handing=0, @insurance=0, @ship_disc=0, @shipping=0, @tax=0, @gross=0, @net=0> (using ==)
Anyway, it seems logical that an Amount
should equate to a Numeric, when it's generated in this manor. I believe that this is especially true since Amount does not carry a currency type, so it's fairly safe to assume that creating an Amount with a Numeric should equate successfully when given the same Numeric.
Although, I could certainly see an argument against this, since Amount has been overloaded to carry fees, handling charges, shipping charges, and more... It just feels counter-intuitive to create a Request with an amount set as a numeric and receive back an instance of an object that cannot be equated to the same numeric from which it was generated.
Feel free to disregard and close out this ticket if you disagree. :)