Sha256: 60a7d9956c5e8b624922ea4ee511f4fc558eff05671c63875317180af03f886f

Contents?: true

Size: 1.16 KB

Versions: 15

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

describe CoinsPaid, '.currency' do
  let(:eth) { instance_double(CoinsPaid::API::Currency, currency: 'ETH') }

  subject(:currency) { described_class.currency(eth.currency) }

  context 'when CoinsPaid API responds correctly' do
    before do
      allow(CoinsPaid::API).to receive(:currencies_list) { currencies }
    end

    context 'and currency exists at CoinsPaid' do
      let(:currencies) do
        [eth, instance_double(CoinsPaid::API::Currency, currency: 'm' + eth.currency)]
      end

      it 'returns requested currency details' do
        expect(currency).to eq eth
      end
    end

    context 'and currency does not exist at CoinsPaid' do
      let(:currencies) do
        [instance_double(CoinsPaid::API::Currency, currency: 'm' + eth.currency)]
      end

      it 'errors' do
        expect { currency }.to raise_error(CoinsPaid::UnknownCurrency)
      end
    end
  end

  context 'when coins paid api errors' do
    before do
      allow(CoinsPaid::API).to receive(:currencies_list).and_raise(CoinsPaid::API::Error)
    end

    it 're-raises error' do
      expect { currency }.to raise_error(CoinsPaid::API::Error)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
coins_paid_rails-2.1.0 spec/currency_spec.rb
coins_paid_rails-2.0.0 spec/currency_spec.rb
coins_paid_rails-1.5.0 spec/currency_spec.rb
coins_paid_rails-1.4.0 spec/currency_spec.rb
coins_paid_rails-1.3.0 spec/currency_spec.rb
coins_paid_rails-1.2.0 spec/currency_spec.rb
coins_paid_rails-1.1.8 spec/currency_spec.rb
coins_paid_rails-1.1.7 spec/currency_spec.rb
coins_paid_rails-1.1.6 spec/currency_spec.rb
coins_paid_rails-1.1.4 spec/currency_spec.rb
coins_paid_rails-1.1.3 spec/currency_spec.rb
coins_paid_rails-1.1.2 spec/currency_spec.rb
coins_paid_rails-1.1.1 spec/currency_spec.rb
coins_paid_rails-1.0.1 spec/currency_spec.rb
coins_paid_rails-1.0.0 spec/currency_spec.rb