flexirest 1.10.11 → 1.11.0

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
  SHA256:
3
- metadata.gz: 60510339b01a0ade8d9cd94686ecec5f431bcb58570c66b48fdc76075faf4d4f
4
- data.tar.gz: 203e88d288ba8fa7f46f757a9aa24177908df116a272b754dc9bd685b19302db
3
+ metadata.gz: e3c99c9dcb4b2b2d6b4992a53d138877f251f0810bb94dc11faf9d9e1b89f9cb
4
+ data.tar.gz: 22554cafc10d12337c1511828ab27471dbadf36de4e211c5383eae96c4fb4c34
5
5
  SHA512:
6
- metadata.gz: f2d51bcbce5d390baa8140cc222cbe69bfb873cb6db399a3e955358b36b39aea6241df15abd8458b79e03d87e3e4643551d2d809dabd0a4ae92c9131e9277da1
7
- data.tar.gz: 73445e4f9be17c311354112a41e7a9290695da228d853e1a67ea063d8aae8a1370f7bf4991fa43bd70a264b608c94416ad005929aa055863686ca919c6fe19ce
6
+ metadata.gz: 3cf855f9fbc7d4f213a19840e11cfa9b816de9b1a0750726538f288f559ec150c7a05a4ae8b63297e8aedcf8002103e2e4ae275cb497793144c83aebc7f7577e
7
+ data.tar.gz: e1a5b90ace51f341a340e5ed32f5c8afc30f2784a38cf7281c621157a8b1233da9b81180ed6a5dc0694f4ac72933793b9e47dcf01d9389583b02bdd7dc3aefbd
@@ -19,7 +19,7 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.5', '2.6', '2.7', '3.0']
22
+ ruby-version: ['3.0', '3.1', '3.2']
23
23
 
24
24
  steps:
25
25
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.0
4
+
5
+ Major change:
6
+
7
+ - Dropped support for Ruby 2.x. Ruby 2.7 will be EOL in 27 days, and anyone can use the previous version 1.10 if they need 2.x support for the last month.
8
+
9
+ Enhancement:
10
+
11
+ - Added caching lines to the quiet! feature (thanks to Romain Gisiger for the issue and PR)
12
+
13
+ ## 1.10.12
14
+
15
+ Enhancement:
16
+
17
+ - Added a quiet! mode to silence logging (thanks to Mujtaba Saboor for the issue and PR)
18
+
3
19
  ## 1.10.11
4
20
 
5
21
  Bugfix:
data/README.md CHANGED
@@ -100,7 +100,7 @@ I've written a TON of documentation on how to use Flexirest and a LITTLE bit on
100
100
  - [HTTP/parse error handling](docs/httpparse-error-handling.md)
101
101
  - [Validation](docs/validation.md)
102
102
  - [Filtering result lists](docs/filtering-result-lists.md)
103
- - [Debugging](docs/debugging.md)
103
+ - [Logging](docs/logging.md)
104
104
  - [XML responses](docs/xml-responses.md)
105
105
 
106
106
 
@@ -1,14 +1,18 @@
1
- # *Flexirest:* Debugging
1
+ # *Flexirest:* Logging
2
2
 
3
- You can turn on verbose debugging to see what is sent to the API server and what is returned in one of these two ways:
3
+ ## Verbose
4
+
5
+ You can turn on verbose logging to see what is sent to the API server and what is returned in one of these two ways:
4
6
 
5
7
  ```ruby
6
8
  class Article < Flexirest::Base
7
- verbose true
9
+ verbose!
8
10
  end
9
11
 
12
+ # or if you prefer
13
+
10
14
  class Person < Flexirest::Base
11
- verbose!
15
+ verbose true
12
16
  end
13
17
  ```
14
18
 
@@ -26,6 +30,21 @@ class Article < Flexirest::Base
26
30
  end
27
31
  ```
28
32
 
33
+ ## Quiet
34
+
35
+ By the same token, if you want to silence all log output from Flexirest, you can use quiet:
36
+
37
+ ```ruby
38
+ class Article < Flexirest::Base
39
+ quiet!
40
+ end
41
+
42
+ # or if you prefer
43
+
44
+ class Person < Flexirest::Base
45
+ quiet true
46
+ end
47
+ ```
29
48
 
30
49
  -----
31
50
 
data/flexirest.gemspec CHANGED
@@ -4,15 +4,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'flexirest/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "flexirest"
8
- spec.version = Flexirest::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ["Andy Jeffries"]
11
- spec.email = ["andy@andyjeffries.co.uk"]
12
- spec.description = %q{Accessing REST services in a flexible way}
13
- spec.summary = %q{This gem is for accessing REST services in a flexible way. ActiveResource already exists for this, but it doesn't work where the resource naming doesn't follow Rails conventions, it doesn't have in-built caching and it's not as flexible in general.}
14
- spec.homepage = "https://andyjeffries.co.uk/"
15
- spec.license = "MIT"
7
+ spec.name = "flexirest"
8
+ spec.version = Flexirest::VERSION
9
+ spec.required_ruby_version = ">= 3.0.0"
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.authors = ["Andy Jeffries"]
12
+ spec.email = ["andy@andyjeffries.co.uk"]
13
+ spec.description = %q{Accessing REST services in a flexible way}
14
+ spec.summary = %q{This gem is for accessing REST services in a flexible way. ActiveResource already exists for this, but it doesn't work where the resource naming doesn't follow Rails conventions, it doesn't have in-built caching and it's not as flexible in general.}
15
+ spec.homepage = "https://andyjeffries.co.uk/"
16
+ spec.license = "MIT"
16
17
 
17
18
  if spec.respond_to?(:metadata)
18
19
  spec.metadata["source_code_uri"] = "https://github.com/flexirest/flexirest"
@@ -26,31 +27,21 @@ Gem::Specification.new do |spec|
26
27
  spec.add_development_dependency "bundler"
27
28
  spec.add_development_dependency "rake"
28
29
  spec.add_development_dependency "rspec", "~> 3"
29
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1.0')
30
- spec.add_development_dependency "webmock", "~> 2.1.0"
31
- spec.add_development_dependency "rspec_junit_formatter", "= 0.2.3"
32
- else
33
- spec.add_development_dependency "webmock"
34
- spec.add_development_dependency "rspec_junit_formatter"
35
- end
30
+ spec.add_development_dependency "webmock"
31
+ spec.add_development_dependency "rspec_junit_formatter"
36
32
  spec.add_development_dependency "simplecov"
37
33
  spec.add_development_dependency "simplecov-rcov"
38
34
  spec.add_development_dependency 'coveralls'
39
- spec.add_development_dependency "api-auth", ">= 1.3.1", "< 2.4"
40
- spec.add_development_dependency 'typhoeus'
35
+ spec.add_development_dependency "api-auth", ">= 2.4"
36
+ spec.add_development_dependency 'faraday-typhoeus'
41
37
  spec.add_development_dependency 'activemodel'
42
38
  spec.add_development_dependency 'rest-client'
43
39
 
44
40
  spec.add_runtime_dependency "mime-types"
45
41
  spec.add_runtime_dependency "multi_json"
46
42
  spec.add_runtime_dependency "crack"
47
- spec.add_runtime_dependency "faraday", "~> 1.0"
43
+ spec.add_runtime_dependency "faraday", "~> 2.7"
48
44
 
49
- # Use Gem::Version to parse the Ruby version for reliable comparison
50
- # ActiveSupport 5+ requires Ruby 2.2.2
51
- if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2')
52
- spec.add_runtime_dependency "activesupport"
53
- else
54
- spec.add_runtime_dependency "activesupport", "< 5.0.0"
55
- end
45
+ spec.add_runtime_dependency "activesupport"
46
+ spec.add_runtime_dependency "actionpack"
56
47
  end
@@ -220,7 +220,7 @@ module Flexirest
220
220
  if value.is_a?(String) && value.length > 50
221
221
  "#{value[0..50]}...".inspect
222
222
  elsif value.is_a?(Date) || value.is_a?(Time)
223
- %("#{value.to_s(:db)}")
223
+ %("#{value.respond_to?(:to_fs) ? value.to_fs(:db) : value.to_s(:db)}")
224
224
  else
225
225
  value.inspect
226
226
  end
@@ -48,16 +48,16 @@ module Flexirest
48
48
  @@cache_store = nil
49
49
  end
50
50
 
51
- def read_cached_response(request)
51
+ def read_cached_response(request, quiet)
52
52
  if cache_store && perform_caching && request.method[:method] == :get
53
53
  key = "#{request.class_name}:#{request.original_url}"
54
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Trying to read from cache"
54
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Trying to read from cache" unless quiet
55
55
  value = cache_store.read(key)
56
56
  value = Marshal.load(value) rescue value
57
57
  end
58
58
  end
59
59
 
60
- def write_cached_response(request, response, result)
60
+ def write_cached_response(request, response, result, quiet)
61
61
  return if result.is_a? Symbol
62
62
  return unless perform_caching
63
63
  return unless !result.respond_to?(:_status) || [200, 304].include?(result._status)
@@ -69,7 +69,7 @@ module Flexirest
69
69
 
70
70
  if cache_store && (headers[:etag] || headers[:expires])
71
71
  key = "#{request.class_name}:#{request.original_url}"
72
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Writing to cache"
72
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Writing to cache" unless quiet
73
73
  cached_response = CachedResponse.new(status:response.status, result:result, response_headers: headers)
74
74
  cached_response.etag = "#{headers[:etag]}" if headers[:etag]
75
75
  cached_response.expires = Time.parse(headers[:expires]) rescue nil if headers[:expires]
@@ -299,6 +299,20 @@ module Flexirest
299
299
  value ? @verbose = value : @verbose
300
300
  end
301
301
 
302
+ def quiet!(options = {})
303
+ @quiet = true
304
+ @verbose = false
305
+ end
306
+
307
+ def quiet(value = nil)
308
+ @quiet ||= false
309
+ if value == true || value == false
310
+ @quiet = value
311
+ @verbose = false if @quiet != false
312
+ end
313
+ @quiet
314
+ end
315
+
302
316
  def translator(value = nil)
303
317
  Flexirest::Logger.warn("DEPRECATION: The translator functionality of Flexirest has been replaced with proxy functionality, see https://github.com/andyjeffries/flexirest#proxying-apis for more information") unless value.nil?
304
318
  @translator ||= nil
@@ -20,7 +20,7 @@ module Flexirest
20
20
  def self.in_parallel(base_url)
21
21
  begin
22
22
  require 'typhoeus'
23
- require 'typhoeus/adapters/faraday'
23
+ require 'typhoeus/adapters/faraday' unless Gem.loaded_specs["faraday-typhoeus"].present?
24
24
  rescue LoadError
25
25
  raise MissingOptionalLibraryError.new("To call '::Flexirest::ConnectionManager.in_parallel' you must include the gem 'Typhoeus' in your Gemfile.")
26
26
  end
@@ -4,7 +4,7 @@ module Flexirest
4
4
  self.class.time_spent += event.duration
5
5
  self.class.calls_made += 1
6
6
  name = '%s (%.1fms)' % [Flexirest.name, event.duration]
7
- Flexirest::Logger.debug " \033[1;4;32m#{name}\033[0m #{event.payload[:name]}"
7
+ Flexirest::Logger.debug " \033[1;4;32m#{name}\033[0m #{event.payload[:name]}" unless event.payload[:quiet]
8
8
  end
9
9
 
10
10
  def self.time_spent=(value)
@@ -184,6 +184,14 @@ module Flexirest
184
184
  end
185
185
  end
186
186
 
187
+ def quiet?
188
+ if object_is_class?
189
+ @object.quiet
190
+ else
191
+ @object.class.quiet
192
+ end
193
+ end
194
+
187
195
  def translator
188
196
  if object_is_class?
189
197
  @object.translator
@@ -226,7 +234,7 @@ module Flexirest
226
234
  @instrumentation_name = "#{class_name}##{@method[:name]}"
227
235
  result = nil
228
236
  cached = nil
229
- ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name) do
237
+ ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name, quiet: quiet?) do
230
238
  @explicit_parameters = explicit_parameters
231
239
  @body = nil
232
240
  prepare_params
@@ -244,7 +252,7 @@ module Flexirest
244
252
  elsif @object.class.new.respond_to?(fake)
245
253
  fake = @object.class.new.send(fake)
246
254
  end
247
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Faked response found"
255
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Faked response found" unless quiet?
248
256
  content_type = @method[:options][:fake_content_type] || "application/json"
249
257
  return handle_response(OpenStruct.new(status:200, body:fake, response_headers:{"X-ARC-Faked-Response" => "true", "Content-Type" => content_type}))
250
258
  end
@@ -260,13 +268,13 @@ module Flexirest
260
268
  append_get_parameters
261
269
  prepare_request_body
262
270
  self.original_url = self.url
263
- cached = original_object_class.read_cached_response(self)
271
+ cached = original_object_class.read_cached_response(self, quiet?)
264
272
  if cached && !cached.is_a?(String)
265
273
  if cached.expires && cached.expires > Time.now
266
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Absolutely cached copy found"
274
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Absolutely cached copy found" unless quiet?
267
275
  return handle_cached_response(cached)
268
276
  elsif cached.etag.to_s != "" #present? isn't working for some reason
269
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Etag cached copy found with etag #{cached.etag}"
277
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Etag cached copy found with etag #{cached.etag}" unless quiet?
270
278
  etag = cached.etag
271
279
  end
272
280
  end
@@ -312,7 +320,7 @@ module Flexirest
312
320
 
313
321
  result = handle_response(response_env, cached)
314
322
  @response_delegate.__setobj__(result)
315
- original_object_class.write_cached_response(self, response_env, result) unless @method[:options][:skip_caching]
323
+ original_object_class.write_cached_response(self, response_env, result, quiet?) unless @method[:options][:skip_caching]
316
324
  end
317
325
 
318
326
  # If this was not a parallel request just return the original result
@@ -564,9 +572,9 @@ module Flexirest
564
572
  connection = Flexirest::ConnectionManager.get_connection(base_url)
565
573
  end
566
574
  if @method[:options][:direct]
567
- Flexirest::Logger.info " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Requesting #{@url}"
575
+ Flexirest::Logger.info " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Requesting #{@url}" unless quiet?
568
576
  else
569
- Flexirest::Logger.info " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Requesting #{connection.base_url}#{@url}"
577
+ Flexirest::Logger.info " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Requesting #{connection.base_url}#{@url}" unless quiet?
570
578
  end
571
579
 
572
580
  if verbose?
@@ -634,7 +642,7 @@ module Flexirest
634
642
 
635
643
  if cached && response.status == 304
636
644
  Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name}" +
637
- ' - Etag copy is the same as the server'
645
+ ' - Etag copy is the same as the server' unless quiet?
638
646
  return handle_cached_response(cached)
639
647
  end
640
648
 
@@ -647,9 +655,9 @@ module Flexirest
647
655
  return @response = Flexirest::PlainResponse.from_response(@response)
648
656
  elsif is_json_response? || is_xml_response?
649
657
  if @response.respond_to?(:proxied) && @response.proxied
650
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Response was proxied, unable to determine size"
658
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Response was proxied, unable to determine size" unless quiet?
651
659
  else
652
- Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Response received #{@response.body.size} bytes"
660
+ Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Response received #{@response.body.size} bytes" unless quiet?
653
661
  end
654
662
  result = generate_new_object(ignore_root: ignore_root, ignore_xml_root: @method[:options][:ignore_xml_root])
655
663
  # TODO: Cleanup when ignore_xml_root is removed
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.10.11"
2
+ VERSION = "1.11.0"
3
3
  end
@@ -229,6 +229,26 @@ describe Flexirest::Configuration do
229
229
  expect(VerboseConfigurationExample3.verbose).to be_truthy
230
230
  end
231
231
 
232
+ it "should default to non-quiet logging" do
233
+ class QuietConfigurationExample1
234
+ include Flexirest::Configuration
235
+ end
236
+ expect(QuietConfigurationExample1.quiet).to be_falsey
237
+ end
238
+
239
+ it "should be able to switch on quiet logging" do
240
+ class QuietConfigurationExample2
241
+ include Flexirest::Configuration
242
+ quiet!
243
+ end
244
+ class QuietConfigurationExample3
245
+ include Flexirest::Configuration
246
+ quiet true
247
+ end
248
+ expect(QuietConfigurationExample2.quiet).to be_truthy
249
+ expect(QuietConfigurationExample3.quiet).to be_truthy
250
+ end
251
+
232
252
  it "should store a translator given" do
233
253
  expect{ ConfigurationExample.send(:translator) }.to_not raise_error
234
254
  ConfigurationExample.send(:translator, String.new)
@@ -35,13 +35,15 @@ describe Flexirest::ConnectionManager do
35
35
  end
36
36
 
37
37
  it "should call 'in_parallel' for a session and yield procedure inside that block" do
38
+ require 'faraday/typhoeus' if Gem.loaded_specs["faraday-typhoeus"].present?
38
39
  Flexirest::Base.adapter = :typhoeus
39
40
  Flexirest::ConnectionManager.get_connection("http://www.example.com").session
40
41
  expect { |b| Flexirest::ConnectionManager.in_parallel("http://www.example.com", &b)}.to yield_control
41
42
  Flexirest::Base._reset_configuration!
42
43
  end
43
44
 
44
- it "should raise Flexirest::MissingOptionalLibraryError if Typhous isn't available" do
45
+ it "should raise Flexirest::MissingOptionalLibraryError if Typhoeus isn't available" do
46
+ require 'faraday/typhoeus' if Gem.loaded_specs["faraday-typhoeus"].present?
45
47
  Flexirest::Base.adapter = :typhoeus
46
48
  Flexirest::ConnectionManager.get_connection("http://www.example.com").session
47
49
  expect(Flexirest::ConnectionManager).to receive(:require).and_raise(LoadError)
@@ -175,13 +175,24 @@ describe Flexirest::Connection do
175
175
  expect(auth_header == "APIAuth id123:TQiQIW6vVaDC5jvh99uTNkxIg6Q=" || auth_header == "APIAuth id123:PMWBThkB8vKbvUccHvoqu9G3eVk=").to be_truthy
176
176
  end
177
177
 
178
- it 'should have an Content-MD5 header' do
179
- stub_request(:put, "www.example.com/foo").
180
- with(body: "body", :headers => @default_headers).
181
- to_return(body: "{result:true}")
182
-
183
- result = @connection.put("/foo", "body", @options)
184
- expect(result.env.request_headers['Content-MD5']).to eq("hBotaJrYa9FhFEdFPCLG/A==")
178
+ if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s < "2.5.0"
179
+ it 'should have an Content-MD5 header' do
180
+ stub_request(:put, "www.example.com/foo").
181
+ with(body: "body", :headers => @default_headers).
182
+ to_return(body: "{result:true}")
183
+
184
+ result = @connection.put("/foo", "body", @options)
185
+ expect(result.env.request_headers['Content-MD5']).to eq("hBotaJrYa9FhFEdFPCLG/A==")
186
+ end
187
+ else
188
+ it 'should have an X-AUTHORIZATION-CONTENT-SHA256 header' do
189
+ stub_request(:put, "www.example.com/foo").
190
+ with(body: "body", :headers => @default_headers).
191
+ to_return(body: "{result:true}")
192
+
193
+ result = @connection.put("/foo", "body", @options)
194
+ expect(result.env.request_headers['X-AUTHORIZATION-CONTENT-SHA256']).to eq("Iw2DWNyOiJC0xY3utikS7i8gNXrpKlzIYbmOaP4xrLU=")
195
+ end
185
196
  end
186
197
  end
187
198
 
@@ -10,11 +10,14 @@ describe Flexirest::Instrumentation do
10
10
  it "should save a load hook to include the instrumentation" do
11
11
  hook_tester = double("HookTester")
12
12
  expect(hook_tester).to receive(:include).with(Flexirest::ControllerInstrumentation)
13
+ if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s >= "2.5.0"
14
+ require "action_controller"
15
+ end
13
16
  ActiveSupport.run_load_hooks(:action_controller, hook_tester)
14
17
  end
15
18
 
16
19
  it "should call ActiveSupport::Notifications.instrument when making any request" do
17
- expect(ActiveSupport::Notifications).to receive(:instrument).with("request_call.flexirest", {:name=>"InstrumentationExampleClient#fake"})
20
+ expect(ActiveSupport::Notifications).to receive(:instrument).with("request_call.flexirest", {:name=>"InstrumentationExampleClient#fake", :quiet=>false})
18
21
  InstrumentationExampleClient.fake
19
22
  end
20
23
 
@@ -332,7 +332,7 @@ describe 'JSON API' do
332
332
  end
333
333
 
334
334
  it 'should raise the relevant Flexirest error' do
335
- expect(-> { make_request }).to raise_error(Flexirest::HTTPNotFoundClientException) do |exception|
335
+ expect { make_request }.to raise_error(Flexirest::HTTPNotFoundClientException) do |exception|
336
336
  expect(exception.result.first.detail).to eq("The record identified by 123456 could not be found")
337
337
  end
338
338
  end
@@ -349,7 +349,7 @@ describe 'JSON API' do
349
349
  end
350
350
 
351
351
  it 'should ignore the "data" key and raise the relevant Flexirest error' do
352
- expect(-> { make_request }).to raise_error(Flexirest::HTTPNotFoundClientException) do |exception|
352
+ expect { make_request }.to raise_error(Flexirest::HTTPNotFoundClientException) do |exception|
353
353
  expect(exception.result.first.detail).to eq("The record identified by 123456 could not be found")
354
354
  end
355
355
  end
@@ -464,7 +464,7 @@ describe 'JSON API' do
464
464
  end
465
465
 
466
466
  it 'should raise exception when an association in the response is not defined in base class' do
467
- expect(-> { subject.includes(:tags).not_recognized_assoc(1) }).to raise_error(Exception)
467
+ expect { subject.includes(:tags).not_recognized_assoc(1) }.to raise_error(Exception)
468
468
  end
469
469
  end
470
470
 
@@ -528,7 +528,7 @@ describe 'JSON API' do
528
528
  article = JsonAPIExample::Article.new
529
529
  article.item = 'item one'
530
530
  article.tags = [tag, author]
531
- expect(-> { article.create }).to raise_error(Exception)
531
+ expect { article.create }.to raise_error(Exception)
532
532
  end
533
533
 
534
534
  it 'should perform a patch request in proper json api format' do
@@ -188,6 +188,13 @@ describe Flexirest::Request do
188
188
  post :create, "/create"
189
189
  end
190
190
 
191
+ class QuietExampleClient < ExampleClient
192
+ base_url "http://www.example.com"
193
+ quiet!
194
+ get :all, "/all"
195
+ post :create, "/create"
196
+ end
197
+
191
198
  class CallbackBodyExampleClient < ExampleClient
192
199
  base_url "http://www.example.com"
193
200
  before_request do |name, request|
@@ -385,11 +392,14 @@ describe Flexirest::Request do
385
392
 
386
393
  it "should use the URL method for Basic auth when basic_auth_method is set to :url (and not include Authorization header)" do
387
394
  mocked_response = ::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{}))
388
- headers_not_including_auth = hash_excluding("Authorization")
389
395
 
390
396
  connection = double(Flexirest::Connection).as_null_object
391
397
  expect(Flexirest::ConnectionManager).to receive(:get_connection).with("http://john:smith@www.example.com").and_return(connection)
392
- expect(connection).to receive(:get).with("/", headers: headers_not_including_auth).and_return(mocked_response)
398
+ expect(connection).to receive(:get) do |path, options|
399
+ expect(path).to eq("/")
400
+ expect(options[:headers]).to eq({"Accept"=>"application/hal+json, application/json;q=0.5", "Content-Type"=>"application/x-www-form-urlencoded; charset=utf-8"})
401
+ end.and_return(mocked_response)
402
+
393
403
  AuthenticatedBasicUrlExampleClient.all
394
404
  end
395
405
 
@@ -1120,6 +1130,16 @@ describe Flexirest::Request do
1120
1130
  VerboseExampleClient.all
1121
1131
  end
1122
1132
 
1133
+ it "should not log if quiet" do
1134
+ connection = double(Flexirest::Connection).as_null_object
1135
+ expect(Flexirest::ConnectionManager).to receive(:get_connection).and_return(connection)
1136
+ expect(connection).to receive(:get).with("/all", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{"Content-Type" => "application/json", "Connection" => "close"})))
1137
+ expect(Flexirest::Logger).to_not receive(:debug)
1138
+ expect(Flexirest::Logger).to_not receive(:info)
1139
+ expect(Flexirest::Logger).to_not receive(:error)
1140
+ QuietExampleClient.all
1141
+ end
1142
+
1123
1143
  it "should return the headers still for 202 responses" do
1124
1144
  fake_location = "https://foo.example.com/123"
1125
1145
  expect_any_instance_of(Flexirest::Connection).
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,8 @@ elsif ENV["TRAVIS"]
12
12
  Coveralls.wear!
13
13
  end
14
14
 
15
+ ActiveSupport::Deprecation.silenced = true
16
+
15
17
  RSpec.configure do |config|
16
18
  config.color = true
17
19
  # config.formatter = 'documentation'
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.10.11
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-22 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,9 +127,6 @@ dependencies:
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 1.3.1
132
- - - "<"
133
130
  - !ruby/object:Gem::Version
134
131
  version: '2.4'
135
132
  type: :development
@@ -137,13 +134,10 @@ dependencies:
137
134
  version_requirements: !ruby/object:Gem::Requirement
138
135
  requirements:
139
136
  - - ">="
140
- - !ruby/object:Gem::Version
141
- version: 1.3.1
142
- - - "<"
143
137
  - !ruby/object:Gem::Version
144
138
  version: '2.4'
145
139
  - !ruby/object:Gem::Dependency
146
- name: typhoeus
140
+ name: faraday-typhoeus
147
141
  requirement: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - ">="
@@ -232,14 +226,14 @@ dependencies:
232
226
  requirements:
233
227
  - - "~>"
234
228
  - !ruby/object:Gem::Version
235
- version: '1.0'
229
+ version: '2.7'
236
230
  type: :runtime
237
231
  prerelease: false
238
232
  version_requirements: !ruby/object:Gem::Requirement
239
233
  requirements:
240
234
  - - "~>"
241
235
  - !ruby/object:Gem::Version
242
- version: '1.0'
236
+ version: '2.7'
243
237
  - !ruby/object:Gem::Dependency
244
238
  name: activesupport
245
239
  requirement: !ruby/object:Gem::Requirement
@@ -254,6 +248,20 @@ dependencies:
254
248
  - - ">="
255
249
  - !ruby/object:Gem::Version
256
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: actionpack
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
257
265
  description: Accessing REST services in a flexible way
258
266
  email:
259
267
  - andy@andyjeffries.co.uk
@@ -280,7 +288,6 @@ files:
280
288
  - docs/body-types.md
281
289
  - docs/caching.md
282
290
  - docs/combined-example.md
283
- - docs/debugging.md
284
291
  - docs/default-parameters.md
285
292
  - docs/empty-body-handling.md
286
293
  - docs/faking-calls.md
@@ -291,6 +298,7 @@ files:
291
298
  - docs/issue_template.md
292
299
  - docs/json-api.md
293
300
  - docs/lazy-loading.md
301
+ - docs/logging.md
294
302
  - docs/migrating-from-activerestclient.md
295
303
  - docs/parallel-requests.md
296
304
  - docs/per-request-parameter-encoding.md
@@ -378,7 +386,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
378
386
  requirements:
379
387
  - - ">="
380
388
  - !ruby/object:Gem::Version
381
- version: '0'
389
+ version: 3.0.0
382
390
  required_rubygems_version: !ruby/object:Gem::Requirement
383
391
  requirements:
384
392
  - - ">="