nbp_exchange 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -0
- data/README.md +9 -11
- data/lib/nbp_exchange/currency.rb +1 -3
- data/lib/nbp_exchange/currency_nodes.rb +0 -3
- data/lib/nbp_exchange/currency_xml.rb +15 -15
- data/lib/nbp_exchange/rate.rb +0 -2
- data/lib/nbp_exchange/version.rb +1 -1
- data/nbp_exchange.gemspec +1 -3
- data/spec/fixtures/xml_names_list.txt +8704 -0
- data/spec/nbp_exchange/currency_spec.rb +7 -9
- data/spec/nbp_exchange/currency_xml_spec.rb +18 -6
- data/spec/nbp_exchange/integration_spec.rb +24 -0
- data/spec/spec_helper.rb +0 -11
- metadata +25 -43
- data/spec/cassettes/xml.yml +0 -0
- data/spec/nbp_exchange/rate_spec.rb +0 -15
@@ -3,32 +3,30 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
module NbpExchange
|
4
4
|
describe Currency do
|
5
5
|
|
6
|
-
let!(:currency){Currency.new(CURRENCY_SYMBOL)}
|
6
|
+
let!(:currency){ Currency.new(CURRENCY_SYMBOL) }
|
7
7
|
|
8
8
|
describe "#name" do
|
9
9
|
it "shoud have name" do
|
10
|
-
currency.name.
|
10
|
+
expect(currency.name).to eq "Euro"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#rate" do
|
15
15
|
context "When rate exists" do
|
16
|
-
let(:expected){Rate.new(currency, EXCHANGE_DATE, 4.4146)}
|
16
|
+
let(:expected){ Rate.new(currency, EXCHANGE_DATE, 4.4146) }
|
17
17
|
|
18
18
|
it "should return average rate for given date" do
|
19
19
|
r = currency.rate(EXCHANGE_DATE)
|
20
|
-
r.average_exchange_rate.
|
20
|
+
expect(r.average_exchange_rate).to eq expected.average_exchange_rate
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context "when rate doesn't exists for this date" do
|
25
|
-
|
26
25
|
it "should raise error" do
|
27
|
-
|
28
|
-
|
29
|
-
}.
|
26
|
+
expect {
|
27
|
+
currency.rate("2001-01-01")
|
28
|
+
}.to raise_error(NbpExchange::NoXMLForThisDate)
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -4,22 +4,34 @@ module NbpExchange
|
|
4
4
|
describe CurrencyXml do
|
5
5
|
|
6
6
|
let(:xml){ CurrencyXml.new(EXCHANGE_DATE)}
|
7
|
+
let(:file_path) { File.expand_path('../../fixtures/xml_names_list.txt', __FILE__) }
|
8
|
+
let(:xml_names_list) { File.read(file_path) }
|
7
9
|
|
8
|
-
|
10
|
+
before do
|
11
|
+
expect(xml).to receive(:xml_names_list).and_return(xml_names_list)
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
describe "#xml_name" do
|
15
|
+
context "when date is #{EXCHANGE_DATE}" do
|
16
|
+
it "should return proper name for the date" do
|
17
|
+
expect(xml.xml_name).to eq "11a212.xml"
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
21
|
+
context "when there is no xml for that date" do
|
22
|
+
it 'raises exception' do
|
23
|
+
xml.date = Date.new(2012,9,1)
|
24
|
+
|
25
|
+
expect { xml.xml_name }.to raise_error(NoXMLForThisDate)
|
26
|
+
end
|
27
|
+
end
|
14
28
|
end
|
15
29
|
|
16
30
|
describe "open_xml" do
|
17
|
-
|
18
31
|
it "should return tabla_kursow" do
|
19
32
|
file = xml.open_xml
|
20
|
-
file[/tabela_kursow/i].
|
33
|
+
expect(file[/tabela_kursow/i]).to eq "tabela_kursow"
|
21
34
|
end
|
22
|
-
|
23
35
|
end
|
24
36
|
end
|
25
37
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Currency rate' do
|
4
|
+
|
5
|
+
describe 'averate_exchange_rate' do
|
6
|
+
let(:currency) { NbpExchange::Currency.new(CURRENCY_SYMBOL) }
|
7
|
+
|
8
|
+
context 'when date after 2012-09-26' do
|
9
|
+
let(:date) { Date.parse("2012-10-19") }
|
10
|
+
|
11
|
+
it 'returns rate for given date' do
|
12
|
+
expect(currency.rate(date).average_exchange_rate).to eq 4.1103
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'date before 2012-09-26' do
|
17
|
+
let(:date) { Date.parse("2012-09-25") }
|
18
|
+
|
19
|
+
it 'returns rate for given date' do
|
20
|
+
expect(currency.rate(date).average_exchange_rate).to eq 4.1475
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,19 +1,8 @@
|
|
1
1
|
require "rspec"
|
2
|
-
#require 'fakeweb'
|
3
|
-
#require 'vcr'
|
4
2
|
require 'nbp_exchange'
|
5
3
|
require 'date'
|
6
4
|
|
7
|
-
#FakeWeb.allow_net_connect = false
|
8
|
-
|
9
|
-
#VCR.config do |c|
|
10
|
-
#c.cassette_library_dir = 'spec/cassettes'
|
11
|
-
#c.stub_with :fakeweb
|
12
|
-
#c.default_cassette_options = { :record => :once }
|
13
|
-
#end
|
14
|
-
|
15
5
|
RSpec.configure do |config|
|
16
|
-
#config.extend VCR::RSpec::Macros
|
17
6
|
end
|
18
7
|
|
19
8
|
CURRENCY_SYMBOL = 'eur'
|
metadata
CHANGED
@@ -1,62 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nbp_exchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michal Wrobel
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec
|
27
|
-
requirement: &70290708337240 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- -
|
24
|
+
- - '>='
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70290708337240
|
36
27
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
39
|
-
none: false
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
40
30
|
requirements:
|
41
|
-
- -
|
31
|
+
- - ~>
|
42
32
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
33
|
+
version: '3.1'
|
44
34
|
type: :development
|
45
35
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: fakeweb
|
49
|
-
requirement: &70290708336400 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ~>
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
|
56
|
-
|
57
|
-
version_requirements: *70290708336400
|
58
|
-
description: ! 'Get average exchange rate for PLN polski zloty from specific date.
|
59
|
-
This lib wraps http://rss.nbp.pl/kursy/xml2/2011/a/dir.aspx site. '
|
40
|
+
version: '3.1'
|
41
|
+
description: 'Get average exchange rate for PLN polski zloty from specific date. This
|
42
|
+
lib wraps http://rss.nbp.pl/kursy/xml2/2011/a/dir.aspx site. '
|
60
43
|
email:
|
61
44
|
- sparrovv@gmail.com
|
62
45
|
executables: []
|
@@ -64,6 +47,7 @@ extensions: []
|
|
64
47
|
extra_rdoc_files: []
|
65
48
|
files:
|
66
49
|
- .gitignore
|
50
|
+
- .travis.yml
|
67
51
|
- Gemfile
|
68
52
|
- README.md
|
69
53
|
- Rakefile
|
@@ -74,39 +58,37 @@ files:
|
|
74
58
|
- lib/nbp_exchange/rate.rb
|
75
59
|
- lib/nbp_exchange/version.rb
|
76
60
|
- nbp_exchange.gemspec
|
77
|
-
- spec/
|
61
|
+
- spec/fixtures/xml_names_list.txt
|
78
62
|
- spec/nbp_exchange/currency_spec.rb
|
79
63
|
- spec/nbp_exchange/currency_xml_spec.rb
|
80
|
-
- spec/nbp_exchange/
|
64
|
+
- spec/nbp_exchange/integration_spec.rb
|
81
65
|
- spec/spec_helper.rb
|
82
66
|
homepage: ''
|
83
67
|
licenses: []
|
68
|
+
metadata: {}
|
84
69
|
post_install_message:
|
85
70
|
rdoc_options: []
|
86
71
|
require_paths:
|
87
72
|
- lib
|
88
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
74
|
requirements:
|
91
|
-
- -
|
75
|
+
- - '>='
|
92
76
|
- !ruby/object:Gem::Version
|
93
77
|
version: '0'
|
94
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
79
|
requirements:
|
97
|
-
- -
|
80
|
+
- - '>='
|
98
81
|
- !ruby/object:Gem::Version
|
99
82
|
version: '0'
|
100
83
|
requirements: []
|
101
84
|
rubyforge_project: nbp_exchange
|
102
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.0.14
|
103
86
|
signing_key:
|
104
|
-
specification_version:
|
87
|
+
specification_version: 4
|
105
88
|
summary: NBP average exchange rates for PLN
|
106
89
|
test_files:
|
107
|
-
- spec/
|
90
|
+
- spec/fixtures/xml_names_list.txt
|
108
91
|
- spec/nbp_exchange/currency_spec.rb
|
109
92
|
- spec/nbp_exchange/currency_xml_spec.rb
|
110
|
-
- spec/nbp_exchange/
|
93
|
+
- spec/nbp_exchange/integration_spec.rb
|
111
94
|
- spec/spec_helper.rb
|
112
|
-
has_rdoc:
|
data/spec/cassettes/xml.yml
DELETED
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
module NbpExchange
|
4
|
-
|
5
|
-
describe Rate do
|
6
|
-
let(:currency){Currency.new(CURRENCY_SYMBOL)}
|
7
|
-
let(:rate){Rate.new(currency, EXCHANGE_DATE, 12)}
|
8
|
-
|
9
|
-
describe ".parse" do
|
10
|
-
it "should parse rate from xml object" do
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|