maremma 4.0.8 → 4.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15d8ec448c94779063007dea0d8dd6425e812eaffda6a1bd5edccbf89522660b
4
- data.tar.gz: c7cb75cb4f844dda296424121a753eb896bf018206da609e9554510fe2e3f4f3
3
+ metadata.gz: 7e790976bf10bd55476209f7f6f6e6cad065cb4f9b110c69c08b4754aa3d5472
4
+ data.tar.gz: 886599b911990f5caed6bcb55bee0a9fe308c5023b0718ec2fa65f0bc6b0836c
5
5
  SHA512:
6
- metadata.gz: c55bcbd4e172d1db6c9062d2148dd27c0ee1f64a0859d0f5aad89ccf1a6b570c828086bfb3f3d58bc86ceed329afd817c6ef3583efa9f5aca38f728406282163
7
- data.tar.gz: e28b0c9a80f47e79c70b3d2d52d65355654cf80f3d1e9386e18e90b83dd42d3b662ff5e28469a8951e06f2f0469888679002d497f5cdebb11a1b91917eb753a2
6
+ metadata.gz: d4ef49ba544067145d829ddf63749cd144c6674d58f85749000b4c219afa31d1dbea519b401879d25c3d443d1b8de87e71811585d1798506a2c977841871ea47
7
+ data.tar.gz: 32b7ac408ea233a65efa50c95f156d868000c914195d1144f0e6432c3fd074346232a8854d8444ad66fe2c3a876f61496736061cfe3dd3555b3b62d04d731dfa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (4.0.8)
4
+ maremma (4.0.9)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  addressable (>= 2.3.6)
7
7
  builder (~> 3.2, >= 3.2.2)
@@ -46,7 +46,7 @@ GEM
46
46
  minitest (5.11.3)
47
47
  multi_json (1.13.1)
48
48
  multipart-post (2.0.0)
49
- nokogiri (1.8.2)
49
+ nokogiri (1.8.3)
50
50
  mini_portile2 (~> 2.3.0)
51
51
  oj (3.6.2)
52
52
  public_suffix (3.0.2)
data/lib/maremma.rb CHANGED
@@ -190,8 +190,12 @@ module Maremma
190
190
  def self.parse_error_response(string)
191
191
  string = parse_response(string)
192
192
 
193
+ string = string['hash'] if string.is_a?(Hash) && string['hash']
194
+
193
195
  if string.is_a?(Hash) && string['error']
194
196
  string['error']
197
+ elsif string.is_a?(Hash) && string['errors']
198
+ string.dig('errors', 0, "title")
195
199
  else
196
200
  string
197
201
  end
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "4.0.8"
2
+ VERSION = "4.0.9"
3
3
  end
data/spec/maremma_spec.rb CHANGED
@@ -202,6 +202,50 @@ describe Maremma do
202
202
  end
203
203
  end
204
204
 
205
+ context "method not allowed" do
206
+ let(:error) { { "errors" => [{ "status" => 405, "title" => "Method not allowed" }]} }
207
+
208
+ it "get json" do
209
+ stub = stub_request(:get, url).to_return(:body => error.to_json, :status => [405], :headers => { "Content-Type" => "application/json" })
210
+ response = subject.get(url, accept: 'json')
211
+ expect(response.body).to eq(error)
212
+ expect(stub).to have_been_requested
213
+ end
214
+
215
+ it "get xml" do
216
+ stub = stub_request(:get, url).to_return(:body => error.to_xml, :status => [405], :headers => { "Content-Type" => "application/xml" })
217
+ response = subject.get(url, accept: 'xml')
218
+ expect(response.body).to eq(error)
219
+ expect(stub).to have_been_requested
220
+ end
221
+
222
+ it "get html" do
223
+ stub = stub_request(:get, url).to_return(:body => error.dig("errors", 0, "title"), :status => [405], :headers => { "Content-Type" => "text/html" })
224
+ response = subject.get(url, accept: 'html')
225
+ expect(response.body).to eq(error)
226
+ expect(stub).to have_been_requested
227
+ end
228
+
229
+ it "head html" do
230
+ stub = stub_request(:head, url).to_return(:body => error.to_s, :status => [405], :headers => { "Content-Type" => "text/html" })
231
+ response = subject.head(url, accept: 'html')
232
+ expect(response.status).to eq(405)
233
+ expect(stub).to have_been_requested
234
+ end
235
+
236
+ it "post xml" do
237
+ stub = stub_request(:post, url).with(:body => post_data.to_xml).to_return(:body => error.to_xml, :status => [405], :headers => { "Content-Type" => "application/xml" })
238
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(error) }
239
+ expect(stub).to have_been_requested
240
+ end
241
+
242
+ it "put xml" do
243
+ stub = stub_request(:put, url).with(:body => post_data.to_xml).to_return(:body => error.to_xml, :status => [405], :headers => { "Content-Type" => "application/xml" })
244
+ subject.put(url, accept: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(error) }
245
+ expect(stub).to have_been_requested
246
+ end
247
+ end
248
+
205
249
  context "request timeout" do
206
250
  it "get json" do
207
251
  stub = stub_request(:get, url).to_return(:status => [408])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.8
4
+ version: 4.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-14 00:00:00.000000000 Z
11
+ date: 2018-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday