Sha256: 4e4ee57b9a0cad92442a4a27b217d671f54f5457c7c1a7c0c92425ca8166f983

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe 'Rates', :vcr => true do
  before do
    CurrencyCloud.reset_session
    CurrencyCloud.environment = :demonstration
    CurrencyCloud.token = 'bbdd421bdda373ea69670c9101fa9197'
  end

  it 'can #find' do
    rates = CurrencyCloud::Rate.find(currency_pair: 'GBPUSD,EURGBP')

    expect(rates).to_not be_nil
    expect(rates.currencies).to_not be_empty

    currencies = rates.currencies
    expect(currencies.length).to eq(2)

    currencies.each do |b|
      expect(b).to_not be_nil
      expect(b).to be_a_kind_of(CurrencyCloud::Rate)
    end

    rate = currencies.first
    expect(rate.currency_pair).to eq('EURGBP')
    expect(rate.bid).to eq('0.71445')
    expect(rate.offer).to eq('0.71508')

    expect(rates.unavailable).to be_empty
  end

  it 'can provided #detailed rate' do
    detailed_rate = CurrencyCloud::Rate.detailed(buy_currency: 'GBP', sell_currency: 'USD', fixed_side: 'buy', amount: '10000')

    expect(detailed_rate).to be_a_kind_of(CurrencyCloud::Rate)
    expect(detailed_rate.client_sell_amount).to eq('15234.00')
    expect(detailed_rate.settlement_cut_off_time).to eq('2015-04-29T14:00:00Z')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
currency_cloud-0.7.2 spec/integration/rates_spec.rb