Sha256: 698dbe8da454cecd009ddabaec90c6e71f4d3a60170cfbfc1c4147a27cb9e0c4

Contents?: true

Size: 957 Bytes

Versions: 7

Compression:

Stored size: 957 Bytes

Contents

require 'spec_helper'
require './lib/fx_lib.rb'

describe 'FxLib' do
  url = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml"

  #Tests for fetching data
  it "should have a method ExchangeRate.fetch_data" do
    lambda do
      FxLib::ExchangeRate.fetch_data(url, 1)
    end.should_not raise_error
  end

  it "should have a method for ExchangeRate.at" do
    lambda do
      FxLib::ExchangeRate.fetch_data(url, 1)
      date = DateTime.new(2013,12,13)
      FxLib::ExchangeRate.at(date, 'GBP', 'USD')
    end.should_not raise_error
  end

  #check no_of_days should be > 0 and < 9
  it 'should check the date range' do
    str = FxLib::ExchangeRate.fetch_data(url, 0)
    str.should eq("Days should be within 1 and 90")
  end

  it 'should calculate exchange rate' do
    FxLib::ExchangeRate.fetch_data(url, 1)
    date = DateTime.new(2013,12,13)
    rate = FxLib::ExchangeRate.at(date, 'GBP', 'USD')
    rate.should eq(1.6270)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fx_lib-0.0.8 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.7 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.6 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.5 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.4 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.3 spec/acceptance/fx_lib_spec.rb
fx_lib-0.0.2 spec/acceptance/fx_lib_spec.rb