Sha256: 84681af4b43efb3e1b094e66e7522b89105b1af79982f55e86a73fcc034cd1f6
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
require 'money' require 'monetize' RSpec.describe Transform::Money do let(:ten_usd) { Money.new(1000, 'USD') } let(:five_nzd) { Money.new(500, 'NZD') } describe '.deserialize' do it 'should transform strings to a Money' do expect(Transform::Money.deserialize('$10.00 USD')).to eq ten_usd expect(Transform::Money.deserialize('$5.00 NZD')).to eq five_nzd end it 'should default to USD' do expect(Transform::Money.deserialize('$10.00')).to eq ten_usd expect(Transform::Money.deserialize('$5.00')).to_not eq five_nzd end it 'should accept an integer' do expect(Transform::Money.deserialize(10)).to eq ten_usd end it 'should return nil if not a string' do expect(Transform::Money.deserialize(true)).to eq nil end end describe '.serialize' do it 'should transform the value to a string' do expect(Transform::Money.serialize(ten_usd)).to eq '$10.00 USD' expect(Transform::Money.serialize(five_nzd)).to eq '$5.00 NZD' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aggro-0.0.4 | spec/lib/aggro/transform/money_spec.rb |
aggro-0.0.3 | spec/lib/aggro/transform/money_spec.rb |
aggro-0.0.2 | spec/lib/aggro/transform/money_spec.rb |