Sha256: 980cdb7ff15191b4c1837cca2929b8e78028102e89c3de641eb8b735ac3bf5fe

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe "Money::Config" do
  describe 'legacy_deprecations' do
    it "respects the default currency" do
      configure(default_currency: 'USD', legacy_deprecations: true) do
        expect(Money.default_currency).to eq("USD")
      end
    end

    it 'defaults to not opt-in to v1' do
      expect(Money::Config.new.legacy_deprecations).to eq(false)
    end

    it 'legacy_deprecations returns true when opting in to v1' do
      configure(legacy_deprecations: true) do
        expect(Money.config.legacy_deprecations).to eq(true)
      end
    end

    it 'sets the deprecations to raise' do
      configure(legacy_deprecations: true) do
        expect { Money.deprecate("test") }.to raise_error(ActiveSupport::DeprecationException)
      end
    end

    it 'legacy_deprecations defaults to NULL_CURRENCY' do
      configure(legacy_default_currency: true) do
        expect(Money.config.default_currency).to eq(Money::NULL_CURRENCY)
      end
    end
  end

  describe 'default_currency' do
    it 'defaults to nil' do
      configure do
        expect(Money.config.default_currency).to eq(nil)
      end
    end

    it 'can be set to a new currency' do
      configure(default_currency: 'USD') do
        expect(Money.config.default_currency).to eq('USD')
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
shopify-money-3.0.0 spec/config_spec.rb
shopify-money-2.2.2 spec/config_spec.rb
shopify-money-2.2.1 spec/config_spec.rb
shopify-money-2.2.0 spec/config_spec.rb
shopify-money-2.0.0 spec/config_spec.rb
shopify-money-1.3.0 spec/config_spec.rb
shopify-money-1.2.1 spec/config_spec.rb
shopify-money-1.2.0 spec/config_spec.rb
shopify-money-1.1.2 spec/config_spec.rb
shopify-money-1.1.1 spec/config_spec.rb
shopify-money-1.1.0 spec/config_spec.rb
shopify-money-1.0.2.pre spec/config_spec.rb