Sha256: 39b7ebd06cf31b29d051f6560452d70a9b95bad0f3356d15ff65222de2d9c8ae

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

require "spec_helper"

describe CurrencyConverter do
  describe ".exchange" do
    it "should return the correct rate" do
      CurrencyConverter.exchange("USD", "USD", 1).should == 1.0
    end
  end

  describe "#validate_currency" do
    describe CurrencyConverter::UnknownCurrency do
      it 'should raise an error on an unsupported currency code' do
        expect { CurrencyConverter.exchange("EUR", "UNKNOWN", 100) }.to raise_error(CurrencyConverter::UnknownCurrency)
        expect { CurrencyConverter.exchange("UNKNOWN", "EUR", 100) }.to raise_error(CurrencyConverter::UnknownCurrency)
      end

      it 'should not raise an error for supported currency codes' do
        expect { CurrencyConverter.exchange("EUR", "USD", 100) }.not_to raise_error(CurrencyConverter::UnknownCurrency)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
currency_converter-1.0.0 spec/currency_converter_spec.rb
currency_converter-0.0.2 spec/currency_converter_spec.rb