fio_api 0.0.5 → 0.0.6

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.travis.yml +7 -2
  4. data/Gemfile +9 -12
  5. data/README.rdoc +8 -3
  6. data/Rakefile +11 -13
  7. data/VERSION +1 -1
  8. data/fio_api.gemspec +57 -33
  9. data/lib/base/account.rb +2 -2
  10. data/lib/base/deserializers/import_response_deserializer.rb +51 -0
  11. data/lib/base/deserializers/list_response_deserializer.rb +47 -36
  12. data/lib/base/list.rb +9 -14
  13. data/lib/base/payment.rb +40 -0
  14. data/lib/base/payments/domestic.rb +13 -0
  15. data/lib/base/payments/status.rb +8 -0
  16. data/lib/base/payments/xml/item.rb +41 -0
  17. data/lib/base/payments/xml/root.rb +30 -0
  18. data/lib/base/request.rb +4 -54
  19. data/lib/base/transaction.rb +2 -2
  20. data/lib/base.rb +2 -6
  21. data/lib/fio_api.rb +16 -10
  22. data/lib/utils/hash.rb +2 -2
  23. data/spec/base/account_spec.rb +4 -8
  24. data/spec/base/deserializers/import_response_deserializer_spec.rb +41 -0
  25. data/spec/base/deserializers/list_response_deserializer_spec.rb +48 -59
  26. data/spec/base/list_spec.rb +36 -23
  27. data/spec/base/payment_spec.rb +38 -0
  28. data/spec/base/payments/domestic_spec.rb +14 -0
  29. data/spec/base/payments/status_spec.rb +13 -0
  30. data/spec/base/payments/xml/root_spec.rb +63 -0
  31. data/spec/base/request_spec.rb +2 -49
  32. data/spec/base/transaction_spec.rb +5 -9
  33. data/spec/fio_api_spec.rb +4 -7
  34. data/spec/fixtures/vcr_cassettes/by_date_range.yml +47 -0
  35. data/spec/fixtures/vcr_cassettes/by_listing_id_and_year.yml +49 -0
  36. data/spec/fixtures/vcr_cassettes/from_last_fetch.yml +44 -0
  37. data/spec/fixtures/vcr_cassettes/import.yml +53 -0
  38. data/spec/fixtures/vcr_cassettes/invalid_import.yml +51 -0
  39. data/spec/fixtures/vcr_cassettes/set_last_fetch_date.yml +44 -0
  40. data/spec/fixtures/vcr_cassettes/set_last_fetch_id.yml +47 -0
  41. data/spec/spec_helper.rb +7 -2
  42. data/spec/utils/hash_spec.rb +10 -15
  43. metadata +70 -24
  44. data/lib/base/deserializer.rb +0 -19
  45. data/spec/base/deserializer_spec.rb +0 -12
@@ -1,54 +1,7 @@
1
- require_relative "../spec_helper"
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe FioAPI::Request do
4
-
5
- it "should have defined token" do
4
+ it 'should have defined token' do
6
5
  expect(FioAPI::Request).to respond_to :token
7
6
  end
8
-
9
- it "should have defined uri" do
10
- expect(FioAPI::Request.new).to respond_to :uri
11
- end
12
-
13
- it "should have defined response" do
14
- expect(FioAPI::Request.new).to respond_to :response
15
- end
16
-
17
- describe "fetch" do
18
- before(:each) do
19
- @response = {response: "response"}
20
- allow(HTTParty).to receive(:get) { @response }
21
- end
22
-
23
- it "should fill the response" do
24
- request = FioAPI::Request.new
25
- request.fetch
26
- expect(request.response).to eq @response
27
- end
28
-
29
- it "should deserialize the response" do
30
- deserializer = FioAPI::ListResponseDeserializer.new
31
- request = FioAPI::Request.new(deserializer: deserializer)
32
- request.fetch
33
- expect(request.response).to eq deserializer.deserialize(@response)
34
- end
35
- end
36
-
37
- describe "uri manipulation" do
38
- before(:each) do
39
- FioAPI.token = "somelongtoken"
40
- @url = "https://www.fio.cz/ib_api/rest/#{FioAPI.token}/transactions.json"
41
- @request = FioAPI::Request.new
42
- end
43
-
44
- it "should construct uri from arguments" do
45
- expect(@request.send(:construct_uri, FioAPI.token, 'transactions.json').to_s).to eq @url
46
- end
47
-
48
- it "should set uri from arguments" do
49
- @request.set_uri FioAPI.token, 'transactions.json'
50
- expect(@request.uri).to eq @url
51
- end
52
-
53
- end
54
7
  end
@@ -1,18 +1,14 @@
1
- require_relative "../spec_helper"
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe FioAPI::Transaction do
4
-
5
- describe "instance attributes" do
6
-
7
- [:transaction_id, :date, :amount, :currency, :account, :account_name, :bank_code,
8
- :bank_name, :ks, :vs, :ss, :user_identification, :message_for_recipient, :transaction_type,
9
- :sender, :detail_info, :comment, :bic, :action_id].each do |attr|
4
+ describe 'instance attributes' do
5
+ %i[transaction_id date amount currency account account_name bank_code
6
+ bank_name ks vs ss user_identification message_for_recipient transaction_type
7
+ sender detail_info comment bic action_id].each do |attr|
10
8
 
11
9
  it "should respond to #{attr}" do
12
10
  expect(FioAPI::Transaction.new).to respond_to(attr)
13
11
  end
14
-
15
12
  end
16
13
  end
17
-
18
14
  end
data/spec/fio_api_spec.rb CHANGED
@@ -1,18 +1,15 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe FioAPI do
4
- it "should setup token" do
5
- token = "some token"
4
+ it 'should setup token' do
5
+ token = 'some token'
6
6
  FioAPI.token = token
7
7
  expect(FioAPI::Request.token).to eq token
8
8
  end
9
9
 
10
- it "should return token" do
11
- token = "some token"
10
+ it 'should return token' do
11
+ token = 'some token'
12
12
  FioAPI::Request.token = token
13
13
  expect(FioAPI.token).to eq token
14
14
  end
15
15
  end
16
-
17
-
18
-
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.fio.cz/ib_api/rest/periods/<%= FioAPI.token %>/2011-01-01/2012-11-25/transactions.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Sat, 02 Jun 2018 21:19:18 GMT
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ Referrer-Policy:
30
+ - strict-origin-when-cross-origin
31
+ X-Intervalusetoken:
32
+ - '20000'
33
+ Content-Type:
34
+ - application/json;charset=UTF-8
35
+ Content-Length:
36
+ - '1253'
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Strict-Transport-Security:
40
+ - max-age=31536000
41
+ body:
42
+ encoding: ASCII-8BIT
43
+ string: !binary |-
44
+ eyJhY2NvdW50U3RhdGVtZW50Ijp7ImluZm8iOnsiYWNjb3VudElkIjoiMjMwMDMxODY1MCIsImJhbmtJZCI6IjIwMTAiLCJjdXJyZW5jeSI6IkNaSyIsImliYW4iOiJDWjc5MjAxMDAwMDAwMDIzMDAzMTg2NTAiLCJiaWMiOiJGSU9CQ1pQUFhYWCIsIm9wZW5pbmdCYWxhbmNlIjowLjAwLCJjbG9zaW5nQmFsYW5jZSI6MTAwLjAwLCJkYXRlU3RhcnQiOiIyMDExLTAxLTAxKzAxMDAiLCJkYXRlRW5kIjoiMjAxMi0xMS0yNSswMTAwIiwieWVhckxpc3QiOm51bGwsImlkTGlzdCI6bnVsbCwiaWRGcm9tIjoxMTYwNTE1NjY5LCJpZFRvIjoxMTYwNTE1NjY5LCJpZExhc3REb3dubG9hZCI6bnVsbH0sInRyYW5zYWN0aW9uTGlzdCI6eyJ0cmFuc2FjdGlvbiI6W3siY29sdW1uMjIiOnsidmFsdWUiOjExNjA1MTU2NjksIm5hbWUiOiJJRCBwb2h5YnUiLCJpZCI6MjJ9LCJjb2x1bW4wIjp7InZhbHVlIjoiMjAxMi0xMC0xOCswMjAwIiwibmFtZSI6IkRhdHVtIiwiaWQiOjB9LCJjb2x1bW4xIjp7InZhbHVlIjoxMDAuMDAsIm5hbWUiOiJPYmplbSIsImlkIjoxfSwiY29sdW1uMTQiOnsidmFsdWUiOiJDWksiLCJuYW1lIjoiTcSbbmEiLCJpZCI6MTR9LCJjb2x1bW4yIjp7InZhbHVlIjoiMjYwMDE3MDIwNSIsIm5hbWUiOiJQcm90acO6xI1ldCIsImlkIjoyfSwiY29sdW1uMTAiOnsidmFsdWUiOiJNYXJ0aW7DrWssIEFkYW0iLCJuYW1lIjoiTsOhemV2IHByb3Rpw7rEjXR1IiwiaWQiOjEwfSwiY29sdW1uMyI6eyJ2YWx1ZSI6IjIwMTAiLCJuYW1lIjoiS8OzZCBiYW5reSIsImlkIjozfSwiY29sdW1uMTIiOnsidmFsdWUiOiJGaW8gYmFua2EsIGEucy4iLCJuYW1lIjoiTsOhemV2IGJhbmt5IiwiaWQiOjEyfSwiY29sdW1uNCI6bnVsbCwiY29sdW1uNSI6bnVsbCwiY29sdW1uNiI6bnVsbCwiY29sdW1uNyI6bnVsbCwiY29sdW1uMTYiOnsidmFsdWUiOiJNaW5pbGFuaSB2a2xhZCBwcm8gRklPIiwibmFtZSI6IlpwcsOhdmEgcHJvIHDFmcOtamVtY2UiLCJpZCI6MTZ9LCJjb2x1bW44Ijp7InZhbHVlIjoiUMWZw61qZW0gcMWZZXZvZGVtIHV2bml0xZkgYmFua3kiLCJuYW1lIjoiVHlwIiwiaWQiOjh9LCJjb2x1bW45IjpudWxsLCJjb2x1bW4xOCI6bnVsbCwiY29sdW1uMjUiOnsidmFsdWUiOiJNaW5pbGFuaSB2a2xhZCBwcm8gRklPIiwibmFtZSI6IktvbWVudMOhxZkiLCJpZCI6MjV9LCJjb2x1bW4yNiI6bnVsbCwiY29sdW1uMTciOnsidmFsdWUiOjIxNjM3MzEwNTEsIm5hbWUiOiJJRCBwb2t5bnUiLCJpZCI6MTd9fV19fX0=
45
+ http_version:
46
+ recorded_at: Sat, 02 Jun 2018 21:19:19 GMT
47
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.fio.cz/ib_api/rest/by-id/<%= FioAPI.token %>/2012/12345/transactions.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 500
19
+ message: Internal Server Error
20
+ headers:
21
+ Date:
22
+ - Sat, 02 Jun 2018 21:21:47 GMT
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ Referrer-Policy:
30
+ - strict-origin-when-cross-origin
31
+ X-Intervalusetoken:
32
+ - '20000'
33
+ Content-Type:
34
+ - text/xml;charset=UTF-8
35
+ Content-Length:
36
+ - '338'
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Strict-Transport-Security:
40
+ - max-age=31536000
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: ASCII-8BIT
45
+ string: !binary |-
46
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PgoKPHJlc3BvbnNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhzaTpub05hbWVzcGFjZVNjaGVtYUxvY2F0aW9uPSJodHRwczovL3d3dy5maW8uY3ovc2NoZW1hL3Jlc3BvbnNlLnhzZCI+Cgk8cmVzdWx0PiAKCQk8ZXJyb3JDb2RlPjIxPC9lcnJvckNvZGU+CgkJPHN0YXR1cz5lcnJvcjwvc3RhdHVzPgoJCTxtZXNzYWdlPlbDvXBpcyBuZWV4aXN0dWplPC9tZXNzYWdlPgoJCTxkZXRhaWw+PC9kZXRhaWw+Cgk8L3Jlc3VsdD4KPC9yZXNwb25zZT4=
47
+ http_version:
48
+ recorded_at: Sat, 02 Jun 2018 21:21:47 GMT
49
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.fio.cz/ib_api/rest/last/<%= FioAPI.token %>/transactions.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 409
19
+ message: Conflict
20
+ headers:
21
+ Date:
22
+ - Sat, 02 Jun 2018 21:21:47 GMT
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ Referrer-Policy:
30
+ - strict-origin-when-cross-origin
31
+ Content-Type:
32
+ - text/plain;charset=UTF-8
33
+ Content-Length:
34
+ - '0'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=31536000
39
+ body:
40
+ encoding: UTF-8
41
+ string: ''
42
+ http_version:
43
+ recorded_at: Sat, 02 Jun 2018 21:21:47 GMT
44
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.fio.cz/ib_api/rest/import/?token=<%= FioAPI.token %>&type=xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: "--------------------------zhBhYIqS35Jglk8M\r\nContent-Disposition:
9
+ form-data; name=\"file\"; filename=\"20180603-11219-1kw9ccy\"\r\nContent-Type:
10
+ application/octet-stream\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Import
11
+ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.fio.cz/schema/importIB.xsd\">\n
12
+ \ <Orders>\n <DomesticTransaction>\n <accountFrom>11111111</accountFrom>\n
13
+ \ <currency>CZK</currency>\n <amount>100.0</amount>\n <accountTo>22222222</accountTo>\n
14
+ \ <bankCode>3030</bankCode>\n <ks/>\n <vs/>\n <ss/>\n <date>2018-06-15</date>\n
15
+ \ <messageForRecipient/>\n <comment/>\n <paymentType>431001</paymentType>\n
16
+ \ </DomesticTransaction>\n </Orders>\n</Import>\n\r\n--------------------------zhBhYIqS35Jglk8M--\r\n"
17
+ headers:
18
+ Content-Type:
19
+ - multipart/form-data; boundary=------------------------zhBhYIqS35Jglk8M
20
+ Boundary:
21
+ - "-----------RubyMultipartPost"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Date:
28
+ - Sat, 02 Jun 2018 23:49:44 GMT
29
+ Server:
30
+ - Apache-Coyote/1.1
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ Content-Type:
38
+ - application/xml;charset=UTF-8
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Strict-Transport-Security:
42
+ - max-age=31536000
43
+ Transfer-Encoding:
44
+ - chunked
45
+ body:
46
+ encoding: UTF-8
47
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><responseImport
48
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.fio.cz/schema/responseImport.xsd"><result><errorCode>0</errorCode><idInstruction>153935923</idInstruction><status>ok</status><sums><sum
49
+ id="CZK"><sumCredit>0</sumCredit><sumDebet>100.0</sumDebet></sum></sums></result><ordersDetails><detail
50
+ id="1"><messages><message status="ok" errorCode="0">OK</message></messages></detail></ordersDetails></responseImport>
51
+ http_version:
52
+ recorded_at: Sat, 02 Jun 2018 23:49:44 GMT
53
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.fio.cz/ib_api/rest/import/?token=<%= FioAPI.token %>&type=xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: "--------------------------8kR1u87fzZKMC9tT\r\nContent-Disposition:
9
+ form-data; name=\"file\"; filename=\"20180603-18534-1yh8r7y\"\r\nContent-Type:
10
+ application/octet-stream\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Import
11
+ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.fio.cz/schema/importIB.xsd\">\n
12
+ \ <Orders>\n <DomesticTransaction>\n <accountFrom>11111111</accountFrom>\n
13
+ \ <currency>CZK</currency>\n <amount/>\n <accountTo>22222222</accountTo>\n
14
+ \ <bankCode>3030</bankCode>\n <ks/>\n <vs/>\n <ss/>\n <date>2018-06-15</date>\n
15
+ \ <messageForRecipient/>\n <comment/>\n <paymentType>431001</paymentType>\n
16
+ \ </DomesticTransaction>\n </Orders>\n</Import>\n\r\n--------------------------8kR1u87fzZKMC9tT--\r\n"
17
+ headers:
18
+ Content-Type:
19
+ - multipart/form-data; boundary=------------------------8kR1u87fzZKMC9tT
20
+ Boundary:
21
+ - "-----------RubyMultipartPost"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Date:
28
+ - Sun, 03 Jun 2018 12:28:55 GMT
29
+ Server:
30
+ - Apache-Coyote/1.1
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ Content-Type:
38
+ - application/xml;charset=UTF-8
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Strict-Transport-Security:
42
+ - max-age=31536000
43
+ Transfer-Encoding:
44
+ - chunked
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: !binary |-
48
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxyZXNwb25zZUltcG9ydCB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4c2k6bm9OYW1lc3BhY2VTY2hlbWFMb2NhdGlvbj0iaHR0cDovL3d3dy5maW8uY3ovc2NoZW1hL3Jlc3BvbnNlSW1wb3J0LnhzZCI+PHJlc3VsdD48ZXJyb3JDb2RlPjExPC9lcnJvckNvZGU+PHN0YXR1cz5lcnJvcjwvc3RhdHVzPjxtZXNzYWdlPlNvdWJvciBtw6EgY2h5YnkgdmUgc3RydWt0dcWZZTogY3ZjLWRhdGF0eXBlLXZhbGlkLjEuMi4xOiAnJyBpcyBub3QgYSB2YWxpZCB2YWx1ZSBmb3IgJ2RlY2ltYWwnLjwvbWVzc2FnZT48L3Jlc3VsdD48L3Jlc3BvbnNlSW1wb3J0Pg==
49
+ http_version:
50
+ recorded_at: Sun, 03 Jun 2018 12:28:55 GMT
51
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.fio.cz/ib_api/rest/set-last-date/<%= FioAPI.token %>/2012-11-25/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Sat, 02 Jun 2018 21:21:47 GMT
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ Referrer-Policy:
30
+ - strict-origin-when-cross-origin
31
+ X-Intervalusetoken:
32
+ - '0'
33
+ Content-Length:
34
+ - '0'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=31536000
39
+ body:
40
+ encoding: UTF-8
41
+ string: ''
42
+ http_version:
43
+ recorded_at: Sat, 02 Jun 2018 21:21:47 GMT
44
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.fio.cz/ib_api/rest/set-last-id/<%= FioAPI.token %>/12345/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 500
19
+ message: Internal Server Error
20
+ headers:
21
+ Date:
22
+ - Sat, 02 Jun 2018 21:21:47 GMT
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ Referrer-Policy:
30
+ - strict-origin-when-cross-origin
31
+ Content-Type:
32
+ - text/xml;charset=UTF-8
33
+ Content-Length:
34
+ - '406'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=31536000
39
+ Connection:
40
+ - close
41
+ body:
42
+ encoding: ASCII-8BIT
43
+ string: !binary |-
44
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PgoKPHJlc3BvbnNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhzaTpub05hbWVzcGFjZVNjaGVtYUxvY2F0aW9uPSJodHRwczovL3d3dy5maW8uY3ovc2NoZW1hL3Jlc3BvbnNlLnhzZCI+Cgk8cmVzdWx0PiAKCQk8ZXJyb3JDb2RlPjMxPC9lcnJvckNvZGU+CgkJPHN0YXR1cz5lcnJvcjwvc3RhdHVzPgoJCTxtZXNzYWdlPlphcsOhxb5rYSBuZW1vaGxhIGLDvXQgbmFzdGF2ZW5hLCBwcm90b8W+ZSBwb2h5YklEIDEyMzQ1IG5hIFZhxaFlbSDDusSNdHUgbmVleGlzdHVqZS48L21lc3NhZ2U+CgkJPGRldGFpbD48L2RldGFpbD4KCTwvcmVzdWx0Pgo8L3Jlc3BvbnNlPg==
45
+ http_version:
46
+ recorded_at: Sat, 02 Jun 2018 21:21:47 GMT
47
+ recorded_with: VCR 4.0.0
data/spec/spec_helper.rb CHANGED
@@ -2,13 +2,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'fio_api'
5
+ require 'vcr'
5
6
 
6
7
  # Requires supporting files with custom matchers and macros, etc,
7
8
  # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
9
10
 
10
- FioAPI.token = "somelongtoken"
11
+ FioAPI.token = 'somelongtoken'
11
12
 
12
13
  RSpec.configure do |config|
14
+ end
13
15
 
16
+ VCR.configure do |config|
17
+ config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
18
+ config.hook_into :webmock
14
19
  end
@@ -1,34 +1,29 @@
1
- require_relative "../spec_helper"
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Hash do
4
-
5
- describe "try_path" do
6
-
7
- it "should respond to try_path method" do
4
+ describe 'try_path' do
5
+ it 'should respond to try_path method' do
8
6
  expect({}).to respond_to(:try_path)
9
7
  end
10
8
 
11
9
  it "should return nil if can't find key" do
12
- expect({}.try_path("key1", "key2")).to be_nil
10
+ expect({}.try_path('key1', 'key2')).to be_nil
13
11
  end
14
12
 
15
- it "should return value on path" do
16
- expect({"key1" => {"key2" => "value"} }.try_path("key1", "key2")).to eq "value"
13
+ it 'should return value on path' do
14
+ expect({ 'key1' => { 'key2' => 'value' } }.try_path('key1', 'key2')).to eq 'value'
17
15
  end
18
16
  end
19
17
  end
20
18
 
21
19
  describe NilClass do
22
-
23
- describe "try_path" do
24
-
25
- it "should respond to try_path method" do
20
+ describe 'try_path' do
21
+ it 'should respond to try_path method' do
26
22
  expect(nil).to respond_to(:try_path)
27
23
  end
28
24
 
29
- it "should return nil" do
30
- expect(nil.try_path("key1", "key2")).to be_nil
25
+ it 'should return nil' do
26
+ expect(nil.try_path('key1', 'key2')).to be_nil
31
27
  end
32
-
33
28
  end
34
29
  end