Sha256: e61e03a7cb38756aecb8cfb51ada18ede47ef47b1f2041cffaf0082f47b891da

Contents?: true

Size: 1.26 KB

Versions: 57

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper.rb'

describe Paypal::Util do
  describe '.formatted_amount' do
    it 'should return String in "xx.yy" format' do
      Paypal::Util.formatted_amount(nil).should == '0.00'
      Paypal::Util.formatted_amount(10).should == '10.00'
      Paypal::Util.formatted_amount(10.02).should == '10.02'
      Paypal::Util.formatted_amount(10.2).should == '10.20'
      Paypal::Util.formatted_amount(10.24).should == '10.24'
      Paypal::Util.formatted_amount(10.255).should == '10.25'
    end
  end

  describe '.to_numeric' do
    it 'should return Numeric' do
      Paypal::Util.to_numeric('10').should be_kind_of(Integer)
      Paypal::Util.to_numeric('10.5').should be_kind_of(Float)
      Paypal::Util.to_numeric('-1.5').should == -1.5
      Paypal::Util.to_numeric('-1').should == -1
      Paypal::Util.to_numeric('0').should == 0
      Paypal::Util.to_numeric('0.00').should == 0
      Paypal::Util.to_numeric('10').should == 10
      Paypal::Util.to_numeric('10.00').should == 10
      Paypal::Util.to_numeric('10.02').should == 10.02
      Paypal::Util.to_numeric('10.2').should == 10.2
      Paypal::Util.to_numeric('10.20').should == 10.2
      Paypal::Util.to_numeric('10.24').should == 10.24
      Paypal::Util.to_numeric('10.25').should == 10.25
    end
  end
end

Version data entries

57 entries across 57 versions & 3 rubygems

Version Path
creative-paypal-express-1.2.1 spec/paypal/util_spec.rb
creative-paypal-express-1.2.0 spec/paypal/util_spec.rb
creative-paypal-express-1.1.0 spec/paypal/util_spec.rb
dfg-paypal-0.8.2 spec/paypal/util_spec.rb
creative-paypal-express-1.0.1.dev2 spec/paypal/util_spec.rb
creative-paypal-express-1.0.1.dev1 spec/paypal/util_spec.rb
creative-paypal-express-1.0.0 spec/paypal/util_spec.rb
creative-paypal-express-0.8.2.4 spec/paypal/util_spec.rb
creative-paypal-express-0.8.2.3 spec/paypal/util_spec.rb
creative-paypal-express-0.8.2.2 spec/paypal/util_spec.rb
creative-paypal-express-0.8.2.1 spec/paypal/util_spec.rb
creative-paypal-express-0.8.2 spec/paypal/util_spec.rb
creative-paypal-express-0.8.1 spec/paypal/util_spec.rb
paypal-express-0.8.1 spec/paypal/util_spec.rb
paypal-express-0.8.0 spec/paypal/util_spec.rb
paypal-express-0.7.1 spec/paypal/util_spec.rb
paypal-express-0.7.0 spec/paypal/util_spec.rb
paypal-express-0.6.0 spec/paypal/util_spec.rb
paypal-express-0.5.5 spec/paypal/util_spec.rb
paypal-express-0.5.4 spec/paypal/util_spec.rb