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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47cf1c23a48bd2918fe49fd5470a9a3b0342e877
4
- data.tar.gz: 5e217cfef265cbe32682ae8a6d1749b4be843428
3
+ metadata.gz: 7e5d860a92f3a3ce66635458548eeffa50fa9bde
4
+ data.tar.gz: 1992115ebc006ee19ad9650e61641ca01ed60a47
5
5
  SHA512:
6
- metadata.gz: fc90cf108ae54f5ee86d6f884e35eecf4fe46e5f7f0b835f2fe5dd77759392f62e3a7cbf1582a749068332e757ddaa672a77894e1858eef88cedcfb621013584
7
- data.tar.gz: 9245bc5bc022f899fb8db5a71339fac3d5ad33d19abb0d13d1dd60d97640f1d751757fd55f1395c24fe32be81dbeac372f2c745a2e75ab817879a6037fdbd9be
6
+ metadata.gz: f3d01faf990a544d09f734d123842a456c2dfdad898549a88b4555f2042b82d24962fc155a26ef24a952e946d4e09731a36625fd2fd9c1f175b8f5cea8920bd1
7
+ data.tar.gz: 76382e77ae23a93feddb2317ecb9b515a9e65e7cfb05cf43dfa8ac0b35b4856c840f527c068fc12937ba914f76c4cbb6dcbea6e8c78bbfb4a10607df3d384d14
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.26
4
+
5
+ Bugfix:
6
+
7
+ - Parameters sent within the URL (e.g. /foo/:bar) should be URI escaped or Flexirest raises an error about unparseable URLs
8
+
3
9
  ## 1.3.25
4
10
 
5
11
  Feature:
@@ -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
- body = @response.body.blank? ? {} : MultiJson.load(@response.body)
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
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.3.25"
2
+ VERSION = "1.3.26"
3
3
  end
@@ -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.25
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-08-09 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler