2017-12-31 17:44:08 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative 'helper'
|
|
|
|
require 'bank'
|
|
|
|
|
|
|
|
describe Bank do
|
|
|
|
around do |test|
|
|
|
|
Currency.db.transaction do
|
|
|
|
test.call
|
|
|
|
raise Sequel::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2018-03-08 02:05:19 +01:00
|
|
|
VCR.insert_cassette 'feed'
|
2017-12-31 17:44:08 +01:00
|
|
|
Currency.dataset.delete
|
|
|
|
end
|
|
|
|
|
2018-03-08 02:05:19 +01:00
|
|
|
after do
|
|
|
|
VCR.eject_cassette
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fetches all rates' do
|
|
|
|
Bank.fetch_all_rates!
|
|
|
|
Currency.count.must_be :positive?
|
|
|
|
end
|
|
|
|
|
2017-12-31 17:44:08 +01:00
|
|
|
it 'fetches current rates' do
|
|
|
|
Bank.fetch_current_rates!
|
|
|
|
Currency.count.must_be :positive?
|
|
|
|
end
|
|
|
|
end
|