spec/mongoid/three_spec.rb in money-rails-1.4.1 vs spec/mongoid/three_spec.rb in money-rails-1.5.0

- old
+ new

@@ -39,15 +39,15 @@ context "when MoneyRails.raise_error_on_money_parsing is true" do before { MoneyRails.raise_error_on_money_parsing = true } 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 + expect { priceable_from_string_with_hyphen }.to raise_error ArgumentError 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 + expect { priceable_from_string_with_unknown_currency }.to raise_error ArgumentError 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 @@ -94,12 +94,13 @@ context "demongoize" do subject { Priceable.first.price } it { is_expected.to be_an_instance_of(Money) } it { is_expected.to eq(Money.new(100, 'EUR')) } - it "returns nil if a nil value was stored" do - nil_priceable = Priceable.create(:price => nil) - expect(nil_priceable.price).to be_nil + it "returns 0 cents in default_currency if a nil value was stored" do + nil_priceable = Priceable.create(price: nil) + expect(nil_priceable.price.cents).to eq(0) + expect(nil_priceable.price.currency).to eq(Money.default_currency) end it 'returns nil if an unknown value was stored' do zero_priceable = Priceable.create(:price => []) expect(zero_priceable.price).to be_nil end