flexirest 1.3.25 → 1.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/flexirest/request.rb +7 -2
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/request_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e5d860a92f3a3ce66635458548eeffa50fa9bde
|
4
|
+
data.tar.gz: 1992115ebc006ee19ad9650e61641ca01ed60a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3d01faf990a544d09f734d123842a456c2dfdad898549a88b4555f2042b82d24962fc155a26ef24a952e946d4e09731a36625fd2fd9c1f175b8f5cea8920bd1
|
7
|
+
data.tar.gz: 76382e77ae23a93feddb2317ecb9b515a9e65e7cfb05cf43dfa8ac0b35b4856c840f527c068fc12937ba914f76c4cbb6dcbea6e8c78bbfb4a10607df3d384d14
|
data/CHANGELOG.md
CHANGED
data/lib/flexirest/request.rb
CHANGED
@@ -271,7 +271,7 @@ module Flexirest
|
|
271
271
|
matches.each do |token|
|
272
272
|
token = token.first[1,999]
|
273
273
|
target = @get_params.delete(token.to_sym) || @post_params.delete(token.to_sym) || @get_params.delete(token.to_s) || @post_params.delete(token.to_s) || ""
|
274
|
-
@url.gsub!(":#{token}", target.to_s)
|
274
|
+
@url.gsub!(":#{token}", URI.escape(target.to_s))
|
275
275
|
end
|
276
276
|
end
|
277
277
|
end
|
@@ -570,7 +570,12 @@ module Flexirest
|
|
570
570
|
if @response.body.is_a?(Array) || @response.body.is_a?(Hash)
|
571
571
|
body = @response.body
|
572
572
|
elsif is_json_response?
|
573
|
-
|
573
|
+
begin
|
574
|
+
body = @response.body.blank? ? {} : MultiJson.load(@response.body)
|
575
|
+
rescue MultiJson::ParseError => exception
|
576
|
+
raise ResponseParseException.new(status:@response.status, body:@response.body, headers:@response.headers)
|
577
|
+
end
|
578
|
+
|
574
579
|
if options[:ignore_root]
|
575
580
|
body = body[options[:ignore_root].to_s]
|
576
581
|
end
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -192,6 +192,11 @@ describe Flexirest::Request do
|
|
192
192
|
ExampleClient.find id:1234
|
193
193
|
end
|
194
194
|
|
195
|
+
it "should pass URL-encode URL parameters" do
|
196
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/foo%20bar", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{})))
|
197
|
+
ExampleClient.find id:"foo bar"
|
198
|
+
end
|
199
|
+
|
195
200
|
it "should accept an integer as the only parameter and use it as id" do
|
196
201
|
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/1234", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{})))
|
197
202
|
ExampleClient.find(1234)
|
@@ -612,6 +617,23 @@ describe Flexirest::Request do
|
|
612
617
|
expect(e.result).to eq(error_content)
|
613
618
|
end
|
614
619
|
|
620
|
+
it "should raise response parse exception for invalid JSON content" do
|
621
|
+
message_content = "Success"
|
622
|
+
expect_any_instance_of(Flexirest::Connection).
|
623
|
+
to receive(:post).
|
624
|
+
with("/create", "first_name=John&should_disappear=true", an_instance_of(Hash)).
|
625
|
+
and_return(::FaradayResponseMock.new(OpenStruct.new(body:message_content, response_headers:{'Content-Type' => 'application/json'}, status:200)))
|
626
|
+
object = ExampleClient.new(first_name:"John", should_disappear:true)
|
627
|
+
begin
|
628
|
+
object.create
|
629
|
+
rescue => e
|
630
|
+
e
|
631
|
+
end
|
632
|
+
expect(e).to be_instance_of(Flexirest::ResponseParseException)
|
633
|
+
expect(e.status).to eq(200)
|
634
|
+
expect(e.body).to eq(message_content)
|
635
|
+
end
|
636
|
+
|
615
637
|
it "should raise response parse exception for 200 response status and non json content type" do
|
616
638
|
error_content = "<h1>malformed json</h1>"
|
617
639
|
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.26
|
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-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|