Sha256: 9cdd4f1181f350fabb256f9a5c389e5aff2d2b52b5f5b8fb04d5340f027aa91f
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require 'test_helper' class RateTest < ActiveSupport::TestCase include RatesHelper test 'retries' do base = Economy::Rates::Base.new base.expects(:call).raises('Error').times(31) base.expects(:sleep).with(60).times(30) silence_stream(STDOUT) do base.fetch end end test 'yahoo' do ids = Economy.currencies.map(&:iso_code).permutation(2).map(&:join).join(',') uri = URI('https://query.yahooapis.com/v1/public/yql') uri.query = URI.encode_www_form( q: "select * from yahoo.finance.xchange where pair in ('#{ids}')", env: 'store://datatables.org/alltableswithkeys', format: 'json' ) assert_response( :yahoo, uri, [['USD','UYU',29.3200]], '200', :single ) assert_response( :yahoo, uri, [['USD','UYU',29.3200],['UYU','USD',0.0341]], '200', :multiple ) assert_response( :yahoo, uri, [], '200', :unknown ) assert_response( :yahoo, uri, [], '500' ) end private def assert_response(service, uri, result, code, name=nil) response = mock_response(service, code, name) Net::HTTP.stubs(:get_response).with(uri).returns response assert_equal result, Economy::Rates::Yahoo.new.fetch end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
economy-4.0.1.0 | test/rate_test.rb |
economy-4.0.0.0 | test/rate_test.rb |