spec/mongoid/three_spec.rb in money-rails-0.12.0 vs spec/mongoid/three_spec.rb in money-rails-1.0.0

- old
+ new

@@ -9,10 +9,11 @@ let!(:priceable_from_hash) { Priceable.create(:price => {:cents=>100, :currency_iso=>"EUR"} )} let!(:priceable_from_hash_with_indifferent_access) { Priceable.create(:price => {:cents=>100, :currency_iso=>"EUR"}.with_indifferent_access) } let(:priceable_from_string_with_hyphen) { Priceable.create(:price => '1-2 EUR' )} + let(:priceable_from_string_with_unknown_currency) { Priceable.create(:price => '1 TLDR') } let(:priceable_with_infinite_precision) { Priceable.create(:price => Money.new(BigDecimal.new('100.1'), 'EUR')) } let(:priceable_with_hash_field) { Priceable.create(:price_hash => { :key1 => Money.new(100, "EUR"), :key2 => Money.new(200, "USD") @@ -40,14 +41,22 @@ after { MoneyRails.raise_error_on_money_parsing = false } it "raises exception if the mongoized value is a String with a hyphen" do expect { priceable_from_string_with_hyphen }.to raise_error end + + it "raises exception if the mongoized value is a String with an unknown currency" do + expect { priceable_from_string_with_unknown_currency }.to raise_error + end end context "when MoneyRails.raise_error_on_money_parsing is false" do it "does not mongoizes correctly a String with hyphen in its middle" do priceable_from_string_with_hyphen.price.should == nil + end + + it "does not mongoize correctly a String with an unknown currency" do + priceable_from_string_with_unknown_currency.price.should == nil end end it "mongoizes correctly a hash of cents and currency" do priceable_from_hash.price.cents.should == 100