flexirest 1.3.10 → 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/flexirest.gemspec +0 -2
- data/lib/flexirest/request.rb +12 -6
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/request_spec.rb +14 -0
- metadata +2 -31
- data/Guardfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ccb5f8a0bd924da53a93a997101f645c495581b
|
4
|
+
data.tar.gz: b5de1887d8f72fd6748e564a1dc35442f8a1469b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a7b8f44082d9368f8826bdfcf5441b354c6bcaddbd7b71cdd2a96439e68aaa0d3eba53a6fc15c64d0d02c02929c8f33241b2b7521a9fd5089e552fa3f3e440
|
7
|
+
data.tar.gz: bea87e9a033c49a21fac8a8b64aee4fc612a3b6aff5f8c94ab70aa2d2844fa4a9a1ce1b3655c69e151e4aeae2c504d4777b1cbbbad3c9ae9aafd092b3a8c6fa4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.12
|
4
|
+
|
5
|
+
Bugfix:
|
6
|
+
|
7
|
+
- The Travis build was breaking because Guard pulls in Listen, which only runs on Ruby 2.2 and above. So I removed Guard so the gem can be tested to work against older Ruby versions still.
|
8
|
+
|
9
|
+
## 1.3.11
|
10
|
+
|
11
|
+
Feature:
|
12
|
+
|
13
|
+
- Made the `Flexirest::*Exception#message` much nicer to help debugging applications, e.g. `Sending PUT to '/enable' returned a 500 with the body of - {"error":"John doesn't exist", "code":1234}`.
|
14
|
+
|
3
15
|
## 1.3.10
|
4
16
|
|
5
17
|
Feature:
|
data/flexirest.gemspec
CHANGED
@@ -26,8 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rspec_junit_formatter"
|
27
27
|
spec.add_development_dependency "simplecov"
|
28
28
|
spec.add_development_dependency "simplecov-rcov"
|
29
|
-
spec.add_development_dependency "guard-rspec"
|
30
|
-
spec.add_development_dependency 'terminal-notifier-guard'
|
31
29
|
spec.add_development_dependency 'coveralls'
|
32
30
|
spec.add_development_dependency "api-auth", ">= 1.3.1"
|
33
31
|
spec.add_development_dependency 'typhoeus'
|
data/lib/flexirest/request.rb
CHANGED
@@ -407,17 +407,17 @@ module Flexirest
|
|
407
407
|
error_response = @response.body
|
408
408
|
end
|
409
409
|
if status == 400
|
410
|
-
raise HTTPBadRequestClientException.new(status:status, result:error_response, url:@url)
|
410
|
+
raise HTTPBadRequestClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
411
411
|
elsif status == 401
|
412
|
-
raise HTTPUnauthorisedClientException.new(status:status, result:error_response, url:@url)
|
412
|
+
raise HTTPUnauthorisedClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
413
413
|
elsif status == 403
|
414
|
-
raise HTTPForbiddenClientException.new(status:status, result:error_response, url:@url)
|
414
|
+
raise HTTPForbiddenClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
415
415
|
elsif status == 404
|
416
|
-
raise HTTPNotFoundClientException.new(status:status, result:error_response, url:@url)
|
416
|
+
raise HTTPNotFoundClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
417
417
|
elsif (400..499).include? status
|
418
|
-
raise HTTPClientException.new(status:status, result:error_response, url:@url)
|
418
|
+
raise HTTPClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
419
419
|
elsif (500..599).include? status
|
420
|
-
raise HTTPServerException.new(status:status, result:error_response, url:@url)
|
420
|
+
raise HTTPServerException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
|
421
421
|
elsif status == 0
|
422
422
|
raise TimeoutException.new("Timed out getting #{response.url}")
|
423
423
|
end
|
@@ -603,6 +603,12 @@ module Flexirest
|
|
603
603
|
@status = options[:status]
|
604
604
|
@result = options[:result]
|
605
605
|
@request_url = options[:url]
|
606
|
+
@raw_response = options[:raw_response]
|
607
|
+
@method = options[:method]
|
608
|
+
end
|
609
|
+
|
610
|
+
def message
|
611
|
+
"Sending #{@method.upcase} to '#{@request_url}' returned a #{@status} with the body of - #{@raw_response}"
|
606
612
|
end
|
607
613
|
end
|
608
614
|
class HTTPClientException < HTTPException ; end
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -494,6 +494,20 @@ describe Flexirest::Request do
|
|
494
494
|
expect(e.result.first_name).to eq("John")
|
495
495
|
end
|
496
496
|
|
497
|
+
it "should return a useful message for errors" do
|
498
|
+
expect_any_instance_of(Flexirest::Connection).
|
499
|
+
to receive(:post).
|
500
|
+
with("/create", "first_name=John&should_disappear=true", an_instance_of(Hash)).
|
501
|
+
and_return(::FaradayResponseMock.new(OpenStruct.new(body:"{\"first_name\":\"John\", \"id\":1234}", response_headers:{}, status:500)))
|
502
|
+
object = ExampleClient.new(first_name:"John", should_disappear:true)
|
503
|
+
begin
|
504
|
+
object.create
|
505
|
+
rescue Flexirest::HTTPServerException => e
|
506
|
+
e
|
507
|
+
end
|
508
|
+
expect(e.message).to eq(%q{Sending POST to '/create' returned a 500 with the body of - {"first_name":"John", "id":1234}})
|
509
|
+
end
|
510
|
+
|
497
511
|
it "should raise a parse exception for invalid JSON returns" do
|
498
512
|
error_content = "<h1>500 Server Error</h1>"
|
499
513
|
expect_any_instance_of(Flexirest::Connection).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexirest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,34 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: guard-rspec
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: terminal-notifier-guard
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
112
|
name: coveralls
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,7 +220,6 @@ files:
|
|
248
220
|
- CHANGELOG.md
|
249
221
|
- CONTRIBUTING.md
|
250
222
|
- Gemfile
|
251
|
-
- Guardfile
|
252
223
|
- LICENSE.txt
|
253
224
|
- Migrating-from-ActiveRestClient.md
|
254
225
|
- README.md
|
data/Guardfile
DELETED