Sha256: 0655a9ef47dcf787f571100ec0b1b91f71a61159250283228eb0f516c47e5fe5

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

require 'spec_helper.rb'

describe Paypal::Payment::Common::Amount do
  let :keys do
    Paypal::Payment::Common::Amount.optional_attributes
  end

  describe '.new' do
    it 'should not allow nil for attributes' do
      amount = Paypal::Payment::Common::Amount.new
      keys.each do |key|
        expect(amount.send(key)).to eq(0)
      end
    end

    it 'should treat all attributes as Numeric' do
      # Integer
      attributes = keys.inject({}) do |attributes, key|
        attributes.merge!(key => "100")
      end
      amount = Paypal::Payment::Common::Amount.new attributes
      keys.each do |key|
        expect(amount.send(key)).to eq(100)
      end

      # Float
      attributes = keys.inject({}) do |attributes, key|
        attributes.merge!(key => "10.25")
      end
      amount = Paypal::Payment::Common::Amount.new attributes
      keys.each do |key|
        expect(amount.send(key)).to eq(10.25)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ianfleeton-paypal-express-0.8.3 spec/paypal/payment/common/amount_spec.rb
ianfleeton-paypal-express-0.8.2 spec/paypal/payment/common/amount_spec.rb