Sha256: de460d0f79467db8b24c752ae1557349e2ccfef0cc33621461ef2a88ac9d76e4

Contents?: true

Size: 1003 Bytes

Versions: 22

Compression:

Stored size: 1003 Bytes

Contents

require 'spec_helper'

describe Spree::LocalizedNumber do

  context ".parse" do
    before do
      I18n.enforce_available_locales = false
      I18n.locale = I18n.default_locale
      I18n.backend.store_translations(:de, { :number => { :currency => { :format => { :delimiter => '.', :separator => ',' } } } })
    end

    after do
      I18n.locale = I18n.default_locale
      I18n.enforce_available_locales = true
    end

    context "with decimal point" do
      it "captures the proper amount for a formatted price" do
        expect(subject.class.parse('1,599.99')).to eql 1599.99
      end
    end

    context "with decimal comma" do
      it "captures the proper amount for a formatted price" do
        I18n.locale = :de
        expect(subject.class.parse('1.599,99')).to eql 1599.99
      end
    end

    context "with a numeric price" do
      it "uses the price as is" do
        I18n.locale = :de
        expect(subject.class.parse(1599.99)).to eql 1599.99
      end
    end
  end

end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
solidus_core-1.2.3 spec/lib/spree/localized_number_spec.rb
solidus_core-1.1.4 spec/lib/spree/localized_number_spec.rb
solidus_core-1.0.7 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.10 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.9 spec/lib/spree/localized_number_spec.rb
solidus_core-1.0.6 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.8 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.2 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.7 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.1 spec/lib/spree/localized_number_spec.rb
solidus_core-1.1.3 spec/lib/spree/localized_number_spec.rb
solidus_core-1.0.5 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.6.1 spec/lib/spree/localized_number_spec.rb
spree_core-3.0.6 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.0 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.0.rc2 spec/lib/spree/localized_number_spec.rb
solidus_core-1.0.4 spec/lib/spree/localized_number_spec.rb
solidus_core-1.1.2 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.0.rc1 spec/lib/spree/localized_number_spec.rb
solidus_core-1.2.0.beta1 spec/lib/spree/localized_number_spec.rb