quicktravel_client 3.1.0 → 3.2.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/CHANGELOG.md +3 -0
- data/lib/quick_travel/adapter_error.rb +12 -9
- data/lib/quick_travel/version.rb +1 -1
- data/spec/booking_spec.rb +13 -0
- data/spec/support/cassettes/booking_non_existant.yml +59 -0
- data/spec/support/coverage_loader.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17de53c54db5f143fc8e6f38e0ddfcf1342970e1
|
4
|
+
data.tar.gz: 638fff7cb6f4adf684782d4f37d1ec2da2dbc563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e04a9695af61b229d37e9b3f9ce7d630f0c5ee7595dacbbb0a437ace9547a5dd53c8f409b54ca9c255c3f943529b0f69253b791e4fa60cf21b4775137a842b4f
|
7
|
+
data.tar.gz: d02ee5b83567d3e2c42ac982aa50f1777fddf0280acd21de2dfbf65db578d0a622d9c84c31e10d71bb419b7875a3ec6d8d8d07acc80d959e6000658c9f5d5b23
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
5
|
|
6
|
+
## [3.2.0]
|
7
|
+
### Changed
|
8
|
+
- Return status with QuickTravel::AdapterError
|
6
9
|
|
7
10
|
## [3.1.0]
|
8
11
|
### Added
|
@@ -1,17 +1,20 @@
|
|
1
1
|
module QuickTravel
|
2
2
|
class AdapterError < StandardError
|
3
3
|
attr_reader :response
|
4
|
+
attr_reader :status
|
4
5
|
|
5
6
|
def initialize(response)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
case response
|
8
|
+
when String
|
9
|
+
@response = { 'error' => response }
|
10
|
+
@status = 422
|
11
|
+
when HTTParty::Response
|
12
|
+
@response = response.parsed_response
|
13
|
+
@status = response.code
|
14
|
+
else
|
15
|
+
fail "Unexpected response type #{response.class}"\
|
16
|
+
"Should be String or HTTParty::Response"
|
17
|
+
end
|
15
18
|
|
16
19
|
error_message = if @response.is_a? Hash
|
17
20
|
@response.fetch('error', "We're sorry, but something went wrong. Please call us.")
|
data/lib/quick_travel/version.rb
CHANGED
data/spec/booking_spec.rb
CHANGED
@@ -186,3 +186,16 @@ describe QuickTravel::Booking, 'when changing state' do
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
|
+
|
190
|
+
describe QuickTravel::Booking, "when booking doesn't exist" do
|
191
|
+
let(:booking) { QuickTravel::Booking.find_by_reference('111111') }
|
192
|
+
|
193
|
+
it 'should raise an error' do
|
194
|
+
VCR.use_cassette('booking_non_existant') do
|
195
|
+
expect{ booking }.to raise_error(QuickTravel::AdapterError) { |exception|
|
196
|
+
expect(exception.status).to eq 404
|
197
|
+
expect(exception.response).to eq({'error' => "Booking not found. It may have been removed due to inactivity"})
|
198
|
+
}
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://test.qt.sealink.com.au:8080/api/bookings/reference/111111.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: access_key=<QT_KEY>
|
9
|
+
headers:
|
10
|
+
Content-Length:
|
11
|
+
- '0'
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 404
|
15
|
+
message: 'Not Found '
|
16
|
+
headers:
|
17
|
+
P3p:
|
18
|
+
- CP="IDC DSP CAO COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
|
19
|
+
Content-Type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
X-Ua-Compatible:
|
22
|
+
- IE=Edge,chrome=1
|
23
|
+
Cache-Control:
|
24
|
+
- no-cache
|
25
|
+
X-Request-Id:
|
26
|
+
- 620e301e261f4038453464856be47a9a
|
27
|
+
X-Runtime:
|
28
|
+
- '0.576024'
|
29
|
+
Vary:
|
30
|
+
- Origin
|
31
|
+
Date:
|
32
|
+
- Fri, 01 Jan 2016 02:32:07 GMT
|
33
|
+
X-Rack-Cache:
|
34
|
+
- miss
|
35
|
+
X-Content-Type-Options:
|
36
|
+
- nosniff
|
37
|
+
X-Download-Options:
|
38
|
+
- noopen
|
39
|
+
X-Frame-Options:
|
40
|
+
- sameorigin
|
41
|
+
X-Permitted-Cross-Domain-Policies:
|
42
|
+
- none
|
43
|
+
X-Xss-Protection:
|
44
|
+
- 1; mode=block
|
45
|
+
Server:
|
46
|
+
- WEBrick/1.3.1 (Ruby/2.2.5/2016-04-26)
|
47
|
+
Content-Length:
|
48
|
+
- '73'
|
49
|
+
Connection:
|
50
|
+
- Keep-Alive
|
51
|
+
Set-Cookie:
|
52
|
+
- _session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTRlNDQwYjQxYmYwODAyM2IwOTVhZWRmZmViZmM3MDFlBjsAVEkiCXVzZXIGOwBGaQY%3D--77cc7c8dff3a0d680d605543218ef1419ead29da;
|
53
|
+
path=/; HttpOnly
|
54
|
+
body:
|
55
|
+
encoding: UTF-8
|
56
|
+
string: '{"error":"Booking not found. It may have been removed due to inactivity"}'
|
57
|
+
http_version:
|
58
|
+
recorded_at: Tue, 04 Jul 2017 07:39:13 GMT
|
59
|
+
recorded_with: VCR 3.0.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quicktravel_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -371,6 +371,7 @@ files:
|
|
371
371
|
- spec/support/cassettes/booking_cancel.yml
|
372
372
|
- spec/support/cassettes/booking_create.yml
|
373
373
|
- spec/support/cassettes/booking_documents.yml
|
374
|
+
- spec/support/cassettes/booking_non_existant.yml
|
374
375
|
- spec/support/cassettes/booking_price_changes.yml
|
375
376
|
- spec/support/cassettes/booking_show.yml
|
376
377
|
- spec/support/cassettes/booking_update.yml
|
@@ -460,6 +461,7 @@ test_files:
|
|
460
461
|
- spec/support/cassettes/booking_cancel.yml
|
461
462
|
- spec/support/cassettes/booking_create.yml
|
462
463
|
- spec/support/cassettes/booking_documents.yml
|
464
|
+
- spec/support/cassettes/booking_non_existant.yml
|
463
465
|
- spec/support/cassettes/booking_price_changes.yml
|
464
466
|
- spec/support/cassettes/booking_show.yml
|
465
467
|
- spec/support/cassettes/booking_update.yml
|