Sha256: cf125a5a3841613b7d120946973d1287fdfa83497558b26b1f0136bc4e9674cb

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

describe "Exchange::ExternalAPI::OpenExchangeRates" do
  before(:all) do
    Exchange.configuration = Exchange::Configuration.new{|c|
      c.cache = {
        :subclass => :no_cache
      }
      c.api = {
        :subclass => :random
      }
    }
  end
  after(:all) do
    Exchange.configuration.reset
  end
  describe "updating rates" do
    subject { Exchange::ExternalAPI::Random.new }
    it "should have usd as base currency" do
      subject.update
      subject.base.should == :usd
    end
    it "should set the timestamp from time.now" do
      time = Time.now
      time.stub! :now => time
      subject.update
      subject.timestamp.should == time.to_i
    end
  end
  describe "rates" do
    subject { Exchange::ExternalAPI::Random.new }
    it "should provide a rate for every ISO currency" do
      subject.update
      Exchange::ISO.currencies.each do |c|
        subject.rates[c].should_not be_nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exchange-1.1.0 spec/exchange/external_api/random_spec.rb
exchange-1.0.4 spec/exchange/external_api/random_spec.rb
exchange-1.0.2 spec/exchange/external_api/random_spec.rb
exchange-1.0.0 spec/exchange/external_api/random_spec.rb