EGP_Rates 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/egp_rates/aaib.rb +0 -18
- data/lib/egp_rates/adib.rb +53 -0
- data/lib/egp_rates/al_ahli_bank_of_kuwait.rb +0 -2
- data/lib/egp_rates/al_baraka_bank.rb +0 -18
- data/lib/egp_rates/alex_bank.rb +54 -0
- data/lib/egp_rates/bank.rb +31 -0
- data/lib/egp_rates/banque_du_caire.rb +0 -28
- data/lib/egp_rates/banque_misr.rb +2 -2
- data/lib/egp_rates/blom.rb +57 -0
- data/lib/egp_rates/cae.rb +0 -2
- data/lib/egp_rates/cbe.rb +0 -20
- data/lib/egp_rates/edbe.rb +56 -0
- data/lib/egp_rates/egb.rb +56 -0
- data/lib/egp_rates/faisal_bank.rb +55 -0
- data/lib/egp_rates/midb.rb +0 -2
- data/lib/egp_rates/nbg.rb +55 -0
- data/lib/egp_rates/saib.rb +0 -2
- data/lib/egp_rates/suez_canal_bank.rb +0 -23
- data/lib/egp_rates/ube.rb +0 -2
- data/lib/egp_rates.rb +60 -0
- data/spec/cassettes/ADIB.yml +457 -0
- data/spec/cassettes/AlexBank.yml +972 -0
- data/spec/cassettes/Blom.yml +868 -0
- data/spec/cassettes/EDBE.yml +69 -0
- data/spec/cassettes/EGB.yml +366 -0
- data/spec/cassettes/FaisalBank.yml +445 -0
- data/spec/cassettes/NBG.yml +760 -0
- data/spec/egp_rates/adib_spec.rb +75 -0
- data/spec/egp_rates/alex_bank_spec.rb +112 -0
- data/spec/egp_rates/banque_misr_spec.rb +4 -4
- data/spec/egp_rates/blom_spec.rb +88 -0
- data/spec/egp_rates/edbe_spec.rb +69 -0
- data/spec/egp_rates/egb_spec.rb +93 -0
- data/spec/egp_rates/faisal_bank_spec.rb +86 -0
- data/spec/egp_rates/nbg_spec.rb +77 -0
- data/spec/egp_rates_spec.rb +80 -2
- metadata +23 -2
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::ADIB do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 5
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 5
|
9
|
+
expect(bank.exchange_rates[:buy].keys).to include(
|
10
|
+
:AED, :EUR, :GBP, :SAR, :USD
|
11
|
+
)
|
12
|
+
expect(bank.exchange_rates[:sell].keys).to include(
|
13
|
+
:AED, :EUR, :GBP, :SAR, :USD
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.new' do
|
18
|
+
it 'initialize instance variables' do
|
19
|
+
expect(bank.sym).to eq :ADIB
|
20
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#exchange_rates' do
|
25
|
+
it 'calls #parse with #raw_exchange_rates' do
|
26
|
+
expect(bank).to receive(:raw_exchange_rates)
|
27
|
+
expect(bank).to receive(:parse)
|
28
|
+
bank.exchange_rates
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#raw_exchange_rates' do
|
33
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
34
|
+
stub_request(:get, /.*adib.*/).to_return(body: '', status: 500)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, '500'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
40
|
+
stub_request(:get, /.*adib.*/).to_return(body: '', status: 200)
|
41
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
42
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns <#Enumerator::Lazy> of 5 rows', vcr: { cassette_name: :ADIB } do
|
46
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
47
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
48
|
+
expect(lazy_enumerator.size).to eq 5
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#parse', vcr: { cassette_name: :ADIB } do
|
53
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
54
|
+
|
55
|
+
it 'returns sell: hash of selling prices' do
|
56
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
57
|
+
AED: 4.7646,
|
58
|
+
EUR: 18.6235,
|
59
|
+
GBP: 21.763,
|
60
|
+
SAR: 4.6669,
|
61
|
+
USD: 17.5
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns buy: hash of buying prices' do
|
66
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
67
|
+
AED: 4.6284,
|
68
|
+
EUR: 17.9639,
|
69
|
+
GBP: 20.9049,
|
70
|
+
SAR: 4.5325,
|
71
|
+
USD: 17.0
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::AlexBank do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 17
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 17
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :AlexBank
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*alexbank.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*alexbank.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Enumerator::Lazy> of 17 rows',
|
40
|
+
vcr: { cassette_name: :AlexBank } do
|
41
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
42
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
43
|
+
expect(lazy_enumerator.size).to eq 17
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#currency_symbol' do
|
48
|
+
%W(#{'UAE Dirham'} Australian Bahraini Canadian Swidish Danish Euro
|
49
|
+
Japanese Swiss British Jordanian Kuwaiti Norwegian Omani Qatari Saudi
|
50
|
+
#{'US Dollar'})
|
51
|
+
.each do |currency|
|
52
|
+
it "returns currency :SYM for #{currency}" do
|
53
|
+
symbols = %i(USD AUD BHD GBP CAD DKK AED EUR CHF SEK JPY JOD NOK OMR QAR
|
54
|
+
SAR KWD)
|
55
|
+
expect(symbols).to include(bank.send(:currency_symbol, currency))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'raises ResponseError when Unknown Currency' do
|
60
|
+
expect { bank.send(:currency_symbol, 'EGYPTIAN POUND') }.to raise_error\
|
61
|
+
EGPRates::ResponseError, 'Unknown currency EGYPTIAN POUND'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#parse', vcr: { cassette_name: :AlexBank } do
|
66
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
67
|
+
|
68
|
+
it 'returns sell: hash of selling prices' do
|
69
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
70
|
+
AED: 4.7695,
|
71
|
+
AUD: 12.9845,
|
72
|
+
BHD: 0.0,
|
73
|
+
CAD: 12.97269,
|
74
|
+
CHF: 17.3969,
|
75
|
+
DKK: 2.50636,
|
76
|
+
EUR: 18.6235,
|
77
|
+
GBP: 21.60025,
|
78
|
+
JOD: 0.0,
|
79
|
+
JPY: 15.77035,
|
80
|
+
KWD: 57.6647,
|
81
|
+
NOK: 2.05232,
|
82
|
+
OMR: 0.0,
|
83
|
+
QAR: 0.0,
|
84
|
+
SAR: 4.6708,
|
85
|
+
SEK: 1.89671,
|
86
|
+
USD: 17.5
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns buy: hash of buying prices' do
|
91
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
92
|
+
AED: 4.63547,
|
93
|
+
AUD: 12.53601,
|
94
|
+
BHD: 0.0,
|
95
|
+
CAD: 12.6069,
|
96
|
+
CHF: 16.89056,
|
97
|
+
DKK: 2.42936,
|
98
|
+
EUR: 18.0747,
|
99
|
+
GBP: 21.12363,
|
100
|
+
JOD: 0.0,
|
101
|
+
JPY: 15.41791,
|
102
|
+
KWD: 55.58396,
|
103
|
+
NOK: 1.98636,
|
104
|
+
OMR: 0.0,
|
105
|
+
QAR: 0.0,
|
106
|
+
SAR: 4.54476,
|
107
|
+
SEK: 1.84222,
|
108
|
+
USD: 17.1
|
109
|
+
)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -78,7 +78,7 @@ describe EGPRates::BanqueMisr do
|
|
78
78
|
AUD: 12.1317,
|
79
79
|
BHD: 42.1928,
|
80
80
|
CAD: 11.8178,
|
81
|
-
CHF:
|
81
|
+
CHF: 16.1754,
|
82
82
|
DKK: 2.334,
|
83
83
|
EUR: 17.3698,
|
84
84
|
GBP: 20.1527,
|
@@ -89,7 +89,7 @@ describe EGPRates::BanqueMisr do
|
|
89
89
|
OMR: 41.3147,
|
90
90
|
QAR: 4.3677,
|
91
91
|
SAR: 4.24,
|
92
|
-
SEK:
|
92
|
+
SEK: 1.7622,
|
93
93
|
USD: 15.91
|
94
94
|
)
|
95
95
|
end
|
@@ -100,7 +100,7 @@ describe EGPRates::BanqueMisr do
|
|
100
100
|
AUD: 11.5524,
|
101
101
|
BHD: 40.6957,
|
102
102
|
CAD: 11.3309,
|
103
|
-
CHF:
|
103
|
+
CHF: 15.5129,
|
104
104
|
DKK: 2.2338,
|
105
105
|
EUR: 16.6256,
|
106
106
|
GBP: 19.2289,
|
@@ -111,7 +111,7 @@ describe EGPRates::BanqueMisr do
|
|
111
111
|
OMR: 39.8339,
|
112
112
|
QAR: 4.2154,
|
113
113
|
SAR: 4.0927,
|
114
|
-
SEK:
|
114
|
+
SEK: 1.6843,
|
115
115
|
USD: 15.35
|
116
116
|
)
|
117
117
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::Blom do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 14
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 14
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :Blom
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*blom.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*blom.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Enumerator::Lazy> of 14 rows',
|
40
|
+
vcr: { cassette_name: :Blom } do
|
41
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
42
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
43
|
+
expect(lazy_enumerator.size).to eq 14
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#parse', vcr: { cassette_name: :Blom } do
|
48
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
49
|
+
|
50
|
+
it 'returns sell: hash of selling prices' do
|
51
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
52
|
+
AED: 4.8324,
|
53
|
+
BHD: 0.0,
|
54
|
+
CAD: 13.155,
|
55
|
+
CHF: 17.6424,
|
56
|
+
DKK: 2.5391,
|
57
|
+
EUR: 18.8896,
|
58
|
+
GBP: 22.0739,
|
59
|
+
JPY: 16.1643,
|
60
|
+
KWD: 58.3498,
|
61
|
+
NOK: 2.0786,
|
62
|
+
QAR: 0.0,
|
63
|
+
SAR: 4.7326,
|
64
|
+
SEK: 1.9238,
|
65
|
+
USD: 17.75
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns buy: hash of buying prices' do
|
70
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
71
|
+
AED: 4.6284,
|
72
|
+
BHD: 0.0,
|
73
|
+
CAD: 12.5332,
|
74
|
+
CHF: 16.7918,
|
75
|
+
DKK: 2.4152,
|
76
|
+
EUR: 17.969,
|
77
|
+
GBP: 20.9151,
|
78
|
+
JPY: 15.3236,
|
79
|
+
KWD: 55.8292,
|
80
|
+
NOK: 1.9747,
|
81
|
+
QAR: 0.0,
|
82
|
+
SAR: 4.5322,
|
83
|
+
SEK: 1.8314,
|
84
|
+
USD: 17.0
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::EDBE do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 5
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 5
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :EDBE
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*edbebank.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*edbebank.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Array> of 20 values', vcr: { cassette_name: :EDBE } do
|
40
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
41
|
+
expect(lazy_enumerator).to be_a Array
|
42
|
+
expect(lazy_enumerator.size).to eq 20
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#parse', vcr: { cassette_name: :EDBE } do
|
47
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
48
|
+
|
49
|
+
it 'returns sell: hash of selling prices' do
|
50
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
51
|
+
CHF: 17.6032,
|
52
|
+
EUR: 18.8363,
|
53
|
+
GBP: 22.0117,
|
54
|
+
JPY: 16.1261,
|
55
|
+
USD: 17.7
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns buy: hash of buying prices' do
|
60
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
61
|
+
CHF: 17.0387,
|
62
|
+
EUR: 18.2281,
|
63
|
+
GBP: 21.2123,
|
64
|
+
JPY: 15.5489,
|
65
|
+
USD: 17.25
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::EGB do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 17
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 17
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :EGB
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*eg-bank.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*eg-bank.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Enumerator::Lazy> of 17 rows', vcr: { cassette_name: :EGB } do
|
40
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
41
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
42
|
+
expect(lazy_enumerator.size).to eq 17
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#parse', vcr: { cassette_name: :EGB } do
|
47
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
48
|
+
|
49
|
+
it 'returns sell: hash of selling prices' do
|
50
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
51
|
+
AED: 4.8326,
|
52
|
+
AUD: 13.167,
|
53
|
+
BHD: 47.0822,
|
54
|
+
CAD: 13.1598,
|
55
|
+
CHF: 17.6529,
|
56
|
+
DKK: 2.5395,
|
57
|
+
EUR: 18.8896,
|
58
|
+
GBP: 22.0739,
|
59
|
+
JOD: 25.0706,
|
60
|
+
JPY: 0.1617,
|
61
|
+
KWD: 58.2349,
|
62
|
+
NOK: 2.0809,
|
63
|
+
OMR: 46.1159,
|
64
|
+
QAR: 4.8753,
|
65
|
+
SAR: 4.7327,
|
66
|
+
SEK: 1.9245,
|
67
|
+
USD: 17.75
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns buy: hash of buying prices' do
|
72
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
73
|
+
AED: 4.6281,
|
74
|
+
AUD: 12.4525,
|
75
|
+
BHD: 45.0689,
|
76
|
+
CAD: 12.5332,
|
77
|
+
CHF: 16.7918,
|
78
|
+
DKK: 2.4152,
|
79
|
+
EUR: 17.9639,
|
80
|
+
GBP: 20.9049,
|
81
|
+
JOD: 23.9437,
|
82
|
+
JPY: 0.1532,
|
83
|
+
KWD: 55.756,
|
84
|
+
NOK: 1.9747,
|
85
|
+
OMR: 44.1558,
|
86
|
+
QAR: 4.6685,
|
87
|
+
SAR: 4.5325,
|
88
|
+
SEK: 1.8314,
|
89
|
+
USD: 17.0
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::FaisalBank do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 13
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 13
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :FaisalBank
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*faisalbank.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*faisalbank.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Enumerator::Lazy> of 9 rows',
|
40
|
+
vcr: { cassette_name: :FaisalBank } do
|
41
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
42
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
43
|
+
expect(lazy_enumerator.size).to eq 13
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#parse', vcr: { cassette_name: :FaisalBank } do
|
48
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
49
|
+
|
50
|
+
it 'returns sell: hash of selling prices' do
|
51
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
52
|
+
AED: 4.8326,
|
53
|
+
CAD: 13.1686,
|
54
|
+
CHF: 17.467,
|
55
|
+
DKK: 2.5187,
|
56
|
+
EUR: 18.7511,
|
57
|
+
GBP: 22.1005,
|
58
|
+
JPY: 0.157918,
|
59
|
+
KWD: 58.2158,
|
60
|
+
NOK: 2.0619,
|
61
|
+
QTR: 4.8748,
|
62
|
+
SAR: 4.7849,
|
63
|
+
SEK: 1.9133,
|
64
|
+
USD: 17.75
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns buy: hash of buying prices' do
|
69
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
70
|
+
AED: 4.6964,
|
71
|
+
CAD: 12.7579,
|
72
|
+
CHF: 16.9267,
|
73
|
+
DKK: 2.4406,
|
74
|
+
EUR: 18.1556,
|
75
|
+
GBP: 21.4245,
|
76
|
+
JPY: 0.152817,
|
77
|
+
KWD: 56.5388,
|
78
|
+
NOK: 1.9973,
|
79
|
+
QTR: 4.7374,
|
80
|
+
SAR: 4.5745,
|
81
|
+
SEK: 1.8545,
|
82
|
+
USD: 17.25
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe EGPRates::NBG do
|
3
|
+
subject(:bank) { described_class.new }
|
4
|
+
|
5
|
+
it 'Live Testing', :live do
|
6
|
+
expect(bank.exchange_rates).to include(:buy, :sell)
|
7
|
+
expect(bank.exchange_rates[:buy].size).to eq 9
|
8
|
+
expect(bank.exchange_rates[:sell].size).to eq 9
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'initialize instance variables' do
|
13
|
+
expect(bank.sym).to eq :NBG
|
14
|
+
expect(bank.instance_variable_get(:@uri)).to be_a URI
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exchange_rates' do
|
19
|
+
it 'calls #parse with #raw_exchange_rates' do
|
20
|
+
expect(bank).to receive(:raw_exchange_rates)
|
21
|
+
expect(bank).to receive(:parse)
|
22
|
+
bank.exchange_rates
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#raw_exchange_rates' do
|
27
|
+
it 'raises ResponseError unless Net::HTTPSuccess', :no_vcr do
|
28
|
+
stub_request(:get, /.*nbg.*/).to_return(body: '', status: 500)
|
29
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
30
|
+
EGPRates::ResponseError, '500'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ResponseError if HTML structure changed', :no_vcr do
|
34
|
+
stub_request(:get, /.*nbg.*/).to_return(body: '', status: 200)
|
35
|
+
expect { bank.send(:raw_exchange_rates) }.to raise_error\
|
36
|
+
EGPRates::ResponseError, 'Unknown HTML'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns <#Enumerator::Lazy> of 9 rows', vcr: { cassette_name: :NBG } do
|
40
|
+
lazy_enumerator = bank.send(:raw_exchange_rates)
|
41
|
+
expect(lazy_enumerator).to be_a Enumerator::Lazy
|
42
|
+
expect(lazy_enumerator.size).to eq 9
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#parse', vcr: { cassette_name: :NBG } do
|
47
|
+
let(:raw_data) { bank.send(:raw_exchange_rates) }
|
48
|
+
|
49
|
+
it 'returns sell: hash of selling prices' do
|
50
|
+
expect(bank.send(:parse, raw_data)[:sell]).to match(
|
51
|
+
CAD: 13.2057,
|
52
|
+
CHF: 17.5162,
|
53
|
+
DKK: 2.5258,
|
54
|
+
EUR: 18.3039,
|
55
|
+
GBP: 22.1628,
|
56
|
+
JPY: 15.8363,
|
57
|
+
SAR: 4.7464,
|
58
|
+
SEK: 1.9187,
|
59
|
+
USD: 17.8
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns buy: hash of buying prices' do
|
64
|
+
expect(bank.send(:parse, raw_data)[:buy]).to match(
|
65
|
+
CAD: 12.721,
|
66
|
+
CHF: 16.8776,
|
67
|
+
DKK: 2.4336,
|
68
|
+
EUR: 18.103,
|
69
|
+
GBP: 21.3624,
|
70
|
+
JPY: 15.2374,
|
71
|
+
SAR: 4.5854,
|
72
|
+
SEK: 1.8492,
|
73
|
+
USD: 17.2
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|