Sha256: 42f0be6293c6005470a2825a43757c30a9bc25d6720cd43c2c073f4a2c857f85

Contents?: true

Size: 996 Bytes

Versions: 4

Compression:

Stored size: 996 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.2.2 spec/exchange/external_api/random_spec.rb
exchange-1.2.1 spec/exchange/external_api/random_spec.rb
exchange-1.2.0 spec/exchange/external_api/random_spec.rb
exchange-1.1.1 spec/exchange/external_api/random_spec.rb