test/test_money.rb in dm-money-0.1.1 vs test/test_money.rb in dm-money-0.1.2
- old
+ new
@@ -6,11 +6,11 @@
Object.send(:remove_const, :Cake) if defined?(Cake)
class ::Cake
include DataMapper::Resource
property :id, Serial
property :type, String
- money :price, :default => BigMoney.new(0, :aud)
+ money :price, :default => BigMoney.new(1, :aud)
end # Cake
end
should 'behave like accessor' do
price = BigMoney.new('2.50', :aud)
@@ -26,12 +26,20 @@
cake = Cake.create(:type => 'sponge', :price => price)
assert_equal price, cake.price
end
end
- should 'have BigMoney default' do
- price = BigMoney.new(0, :aud)
+ should 'have default' do
+ price = BigMoney.new(1, :aud)
cake = Cake.create(:type => 'banana')
assert_equal price, cake.price
+ end
+
+ should 'have default currency' do
+ assert_equal BigMoney.currency(:aud).to_s, Cake.properties[:price_currency].default
+ end
+
+ should 'have default amount' do
+ assert_equal BigDecimal.new('1'), Cake.properties[:price_amount].default
end
end
end # TestMoney