money-open-exchange-rates 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5a908e851c07a69ab0aca84da9edb9c1f596112
4
- data.tar.gz: d63b70c7f7bd0300e44bdee7b723c558e862ef62
3
+ metadata.gz: 5d4627d2362f3d25776f0c16eac6dc34cd2b5ff9
4
+ data.tar.gz: cbeee2c8c0ba9be2e6b14104f72b13b18f4f2ad0
5
5
  SHA512:
6
- metadata.gz: d4dfe2d85a96e772b193cfc8bd2986c2caf8e02e56fa1eb46ce86e9993d47b80d00a26eb243a1d6a3b51de56d8259a8de674217e99e89731e94a8665415c9c95
7
- data.tar.gz: bd056b885c383fa246593a57685c61a2f33001ad1a120f5415d9d982272a03942af9bb9599976078912a424cf2626e0cb687fc8cce2064a728e175bad4b2ea99
6
+ metadata.gz: 78e27850a154eec72b5ba6effbd4cdc0fcecaa23d75a4f2fc77b7e6da885cff9026ece0d2fa9cecca10c0d00921b11a64ddaf7011717fd5fbf79f6172f8d6fe0
7
+ data.tar.gz: 359705aa410f98fdd525f5d91da0b9437178461568725f1b12e2d7ffe53f8e5b91ac8a89e3b4470a0d853e1ce674d35f16d0baf9fba447f1779325b41ed7ae5a
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2011 Laurent Arnoud <laurent@spkdev.net>
3
+ Copyright (c) 2011-2015 Laurent Arnoud <laurent@spkdev.net>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -73,7 +73,7 @@ shpupti (1)
73
73
 
74
74
  The MIT License
75
75
 
76
- Copyright © 2014 Laurent Arnoud <laurent@spkdev.net>
76
+ Copyright © 2011-2015 Laurent Arnoud <laurent@spkdev.net>
77
77
 
78
78
  ---
79
79
  [![Gem Version](https://badge.fury.io/rb/money-open-exchange-rates.svg)](https://rubygems.org/gems/money-open-exchange-rates)
@@ -12,7 +12,7 @@ class Money
12
12
  # OpenExchangeRatesBank base class
13
13
  class OpenExchangeRatesBank < Money::Bank::VariableExchange
14
14
  OER_URL = 'http://openexchangerates.org/latest.json'
15
- SECURE_OER_URL = OER_URL.tr('http:', 'https:')
15
+ SECURE_OER_URL = OER_URL.gsub('http:', 'https:')
16
16
 
17
17
  attr_accessor :cache, :app_id, :secure_connection
18
18
  attr_reader :doc, :oer_rates, :rates_expiration, :ttl_in_seconds
@@ -161,6 +161,7 @@ describe Money::Bank::OpenExchangeRatesBank do
161
161
  subject.secure_connection = true
162
162
  subject.app_id = TEST_APP_ID
163
163
  subject.source_url.must_equal "#{secure_url}?app_id=#{TEST_APP_ID}"
164
+ subject.source_url.must_include "https://"
164
165
  end
165
166
  end
166
167
 
@@ -256,34 +257,34 @@ describe Money::Bank::OpenExchangeRatesBank do
256
257
  before do
257
258
  subject.app_id = TEST_APP_ID
258
259
  subject.ttl_in_seconds = 1000
259
- @usd_eur_rate = 0.655
260
- subject.add_rate('USD', 'EUR', @usd_eur_rate)
260
+ @old_usd_eur_rate = 0.655
261
+ # see test/latest.json +52
262
+ @new_usd_eur_rate = 0.79085
263
+ subject.add_rate('USD', 'EUR', @old_usd_eur_rate)
261
264
  subject.cache = temp_cache_path
262
- stub(OpenURI::OpenRead).open(url) do
263
- File.read cache_path
264
- end
265
+ stub(subject).read_from_url { File.read cache_path }
266
+ subject.save_rates
265
267
  end
266
268
 
267
- describe 'when the ttl has expired' do
268
- before do
269
- new_time = Time.now + 1001
270
- Timecop.freeze(new_time)
271
- end
272
-
273
- after do
274
- Timecop.return
275
- end
269
+ after do
270
+ File.delete temp_cache_path
271
+ end
276
272
 
273
+ describe 'when the ttl has expired' do
277
274
  it 'should update the rates' do
278
- subject.update_rates
279
- subject.get_rate('USD', 'EUR').wont_equal @usd_eur_rate
275
+ subject.get_rate('USD', 'EUR').must_equal @old_usd_eur_rate
276
+ Timecop.freeze(Time.now + 1001) do
277
+ subject.get_rate('USD', 'EUR').wont_equal @old_usd_eur_rate
278
+ subject.get_rate('USD', 'EUR').must_equal @new_usd_eur_rate
279
+ end
280
280
  end
281
281
 
282
282
  it 'updates the next expiration time' do
283
- exp_time = Time.now + 1000
284
-
285
- subject.expire_rates
286
- subject.rates_expiration.must_equal exp_time
283
+ Timecop.freeze(Time.now + 1001) do
284
+ exp_time = Time.now + 1000
285
+ subject.expire_rates
286
+ subject.rates_expiration.must_equal exp_time
287
+ end
287
288
  end
288
289
  end
289
290
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money-open-exchange-rates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Arnoud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-line
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: pry
71
85
  requirement: !ruby/object:Gem::Requirement