flexirest 1.10.12 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +2 -5
- data/CHANGELOG.md +16 -0
- data/flexirest.gemspec +18 -26
- data/lib/flexirest/base_without_validation.rb +1 -1
- data/lib/flexirest/caching.rb +10 -3
- data/lib/flexirest/connection_manager.rb +1 -1
- data/lib/flexirest/request.rb +1 -1
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/caching_spec.rb +55 -26
- data/spec/lib/connection_manager_spec.rb +3 -1
- data/spec/lib/connection_spec.rb +18 -7
- data/spec/lib/instrumentation_spec.rb +3 -0
- data/spec/spec_helper.rb +1 -0
- metadata +35 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '036069384b97e0fbcf4e73c9e75154569cffbb9cbfcb8dfcda4ccfc4ef75cca2'
|
4
|
+
data.tar.gz: 3099f07f5284601a68ebba405a60e485975635b5306b72f2ead2090509bdb901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d64a00ceea9f1a9ee61dcdaedf64dbcc8eae7b9f4f3d20943e7b9209dd7d98acd08138a9c149d0f7cb7aa03740131030580c45f4d153e2f47df999e6415a61
|
7
|
+
data.tar.gz: 026a430bdc41b68adc6e46c42dc69983fca9ef431fb3cc068c96fb3714c687209393d15e66879bb46c3f26ba3f9e38dd08b94620a7d8b2f20d392f08690031fd
|
data/.github/workflows/build.yml
CHANGED
@@ -19,15 +19,12 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
strategy:
|
21
21
|
matrix:
|
22
|
-
ruby-version: ['
|
22
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
23
23
|
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v2
|
26
26
|
- name: Set up Ruby
|
27
|
-
|
28
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
-
# uses: ruby/setup-ruby@v1
|
30
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
27
|
+
uses: ruby/setup-ruby@v1
|
31
28
|
with:
|
32
29
|
ruby-version: ${{ matrix.ruby-version }}
|
33
30
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.11.1
|
4
|
+
|
5
|
+
Enhancement:
|
6
|
+
|
7
|
+
- Add automatic expiry of cached responses based on the Expires header if set (thanks to Romain Gisiger for the issue and PR)
|
8
|
+
|
9
|
+
## 1.11.0
|
10
|
+
|
11
|
+
Major change:
|
12
|
+
|
13
|
+
- 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.
|
14
|
+
|
15
|
+
Enhancement:
|
16
|
+
|
17
|
+
- Added caching lines to the quiet! feature (thanks to Romain Gisiger for the issue and PR)
|
18
|
+
|
3
19
|
## 1.10.12
|
4
20
|
|
5
21
|
Enhancement:
|
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
|
8
|
-
spec.version
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
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,22 @@ 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
|
-
|
30
|
-
|
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", ">=
|
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'
|
39
|
+
spec.add_development_dependency 'timecop'
|
43
40
|
|
44
41
|
spec.add_runtime_dependency "mime-types"
|
45
42
|
spec.add_runtime_dependency "multi_json"
|
46
43
|
spec.add_runtime_dependency "crack"
|
47
|
-
spec.add_runtime_dependency "faraday", "~>
|
44
|
+
spec.add_runtime_dependency "faraday", "~> 2.7"
|
48
45
|
|
49
|
-
|
50
|
-
|
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
|
46
|
+
spec.add_runtime_dependency "activesupport"
|
47
|
+
spec.add_runtime_dependency "actionpack"
|
56
48
|
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
|
data/lib/flexirest/caching.rb
CHANGED
@@ -57,7 +57,7 @@ module Flexirest
|
|
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,12 +69,19 @@ 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]
|
76
76
|
if cached_response.etag.present? || cached_response.expires
|
77
|
-
|
77
|
+
options = {}
|
78
|
+
if cached_response.expires.present?
|
79
|
+
exp_in_seconds = cached_response.expires.utc - Time.now.utc
|
80
|
+
return unless exp_in_seconds.positive?
|
81
|
+
|
82
|
+
options[:expires_in] = exp_in_seconds
|
83
|
+
end
|
84
|
+
cache_store.write(key, Marshal.dump(cached_response), options)
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
@@ -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
|
data/lib/flexirest/request.rb
CHANGED
@@ -320,7 +320,7 @@ module Flexirest
|
|
320
320
|
|
321
321
|
result = handle_response(response_env, cached)
|
322
322
|
@response_delegate.__setobj__(result)
|
323
|
-
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]
|
324
324
|
end
|
325
325
|
|
326
326
|
# If this was not a parallel request just return the original result
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/caching_spec.rb
CHANGED
@@ -72,28 +72,21 @@ describe Flexirest::Caching do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should use a custom cache store if a valid one is manually set" do
|
75
|
-
class CachingExampleCacheStore1
|
76
|
-
def read(key) ; end
|
77
|
-
def write(key, value, options={}) ; end
|
78
|
-
def fetch(key, &block) ; end
|
79
|
-
end
|
75
|
+
class CachingExampleCacheStore1 < ActiveSupport::Cache::MemoryStore; end
|
80
76
|
cache_store = CachingExampleCacheStore1.new
|
81
77
|
Flexirest::Base.cache_store = cache_store
|
82
78
|
expect(Flexirest::Base.cache_store).to eq(cache_store)
|
83
79
|
end
|
84
80
|
|
85
81
|
it "should error if you try to use a custom cache store that doesn't match the required interface" do
|
86
|
-
class CachingExampleCacheStore2
|
87
|
-
|
88
|
-
def fetch(key, &block) ; end
|
82
|
+
class CachingExampleCacheStore2 < ActiveSupport::Cache::MemoryStore
|
83
|
+
undef_method :read
|
89
84
|
end
|
90
|
-
class CachingExampleCacheStore3
|
91
|
-
|
92
|
-
def fetch(key, &block) ; end
|
85
|
+
class CachingExampleCacheStore3 < ActiveSupport::Cache::MemoryStore
|
86
|
+
undef_method :write
|
93
87
|
end
|
94
|
-
class CachingExampleCacheStore4
|
95
|
-
|
96
|
-
def write(key, value, options={}) ; end
|
88
|
+
class CachingExampleCacheStore4 < ActiveSupport::Cache::MemoryStore
|
89
|
+
undef_method :fetch
|
97
90
|
end
|
98
91
|
|
99
92
|
expect{ Flexirest::Base.cache_store = CachingExampleCacheStore2.new }.to raise_error(Flexirest::InvalidCacheStoreException)
|
@@ -109,11 +102,7 @@ describe Flexirest::Caching do
|
|
109
102
|
context "Reading/writing to the cache" do
|
110
103
|
before :each do
|
111
104
|
Object.send(:remove_const, :CachingExampleCacheStore5) if defined?(CachingExampleCacheStore5)
|
112
|
-
class CachingExampleCacheStore5
|
113
|
-
def read(key) ; end
|
114
|
-
def write(key, value, options={}) ; end
|
115
|
-
def fetch(key, &block) ; end
|
116
|
-
end
|
105
|
+
class CachingExampleCacheStore5 < ActiveSupport::Cache::MemoryStore; end
|
117
106
|
|
118
107
|
class Person < Flexirest::Base
|
119
108
|
perform_caching true
|
@@ -122,7 +111,7 @@ describe Flexirest::Caching do
|
|
122
111
|
put :save_all, "/"
|
123
112
|
end
|
124
113
|
|
125
|
-
Person.cache_store = CachingExampleCacheStore5.new
|
114
|
+
Person.cache_store = CachingExampleCacheStore5.new({ expires_in: 1.day.to_i }) # default cache expiration
|
126
115
|
|
127
116
|
@etag = "6527914a91e0c5769f6de281f25bd891"
|
128
117
|
@cached_object = Person.new(first_name:"Johnny")
|
@@ -173,7 +162,7 @@ describe Flexirest::Caching do
|
|
173
162
|
expect(result.first_name).to eq new_name
|
174
163
|
end
|
175
164
|
|
176
|
-
it "should read from the cache store, and not call the server if there's a hard expiry" do
|
165
|
+
it "should read from the cache store, and not call the server if there's a hard expiry not passed yet" do
|
177
166
|
cached_response = Flexirest::CachedResponse.new(
|
178
167
|
status:200,
|
179
168
|
result:@cached_object,
|
@@ -184,6 +173,18 @@ describe Flexirest::Caching do
|
|
184
173
|
expect(ret.first_name).to eq("Johnny")
|
185
174
|
end
|
186
175
|
|
176
|
+
it "should not read from the cache store, and call the server if there's a hard expiry already passed" do
|
177
|
+
cached_response = Flexirest::CachedResponse.new(
|
178
|
+
status:200,
|
179
|
+
result:@cached_object,
|
180
|
+
expires:Time.now + 30)
|
181
|
+
Timecop.travel(Time.now + 60)
|
182
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
183
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{})))
|
184
|
+
ret = Person.all
|
185
|
+
Timecop.return
|
186
|
+
end
|
187
|
+
|
187
188
|
it "cache read objects shouldn't be marked as changed" do
|
188
189
|
cached_response = Flexirest::CachedResponse.new(
|
189
190
|
status:200,
|
@@ -208,7 +209,7 @@ describe Flexirest::Caching do
|
|
208
209
|
expect(ret.first_name).to eq("Johnny")
|
209
210
|
end
|
210
211
|
|
211
|
-
it "should restore a result iterator from the cache store, if there's a hard expiry" do
|
212
|
+
it "should restore a result iterator from the cache store, if there's a hard expiry not passed yet" do
|
212
213
|
class CachingExample3 < Flexirest::Base ; end
|
213
214
|
object = Flexirest::ResultIterator.new(double(status: 200))
|
214
215
|
object << CachingExample3.new(first_name:"Johnny")
|
@@ -226,6 +227,26 @@ describe Flexirest::Caching do
|
|
226
227
|
expect(ret._status).to eq(200)
|
227
228
|
end
|
228
229
|
|
230
|
+
it "should not restore a result iterator from the cache store, if there's a hard expiry already passed" do
|
231
|
+
class CachingExample3 < Flexirest::Base ; end
|
232
|
+
object = Flexirest::ResultIterator.new(double(status: 200))
|
233
|
+
object << CachingExample3.new(first_name:"Johnny")
|
234
|
+
object << CachingExample3.new(first_name:"Billy")
|
235
|
+
etag = "6527914a91e0c5769f6de281f25bd891"
|
236
|
+
cached_response = Flexirest::CachedResponse.new(
|
237
|
+
status:200,
|
238
|
+
result:object,
|
239
|
+
etag:etag,
|
240
|
+
expires:Time.now + 30)
|
241
|
+
Timecop.travel(Time.now + 60)
|
242
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
243
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"[{\"first_name\":\"Billy\"}]", response_headers:{})))
|
244
|
+
ret = Person.all
|
245
|
+
expect(ret.first.first_name).to eq("Billy")
|
246
|
+
expect(ret._status).to eq(200)
|
247
|
+
Timecop.return
|
248
|
+
end
|
249
|
+
|
229
250
|
it "should not write the response to the cache unless it has caching headers" do
|
230
251
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
231
252
|
expect_any_instance_of(CachingExampleCacheStore5).not_to receive(:write)
|
@@ -233,9 +254,9 @@ describe Flexirest::Caching do
|
|
233
254
|
Person.all
|
234
255
|
end
|
235
256
|
|
236
|
-
it "should write the response to the cache if there's an etag" do
|
257
|
+
it "should write the response to the cache without expires_in option if there's an etag" do
|
237
258
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
238
|
-
expect_any_instance_of(CachingExampleCacheStore5).to receive(:write).once.with("Person:/", an_instance_of(String),
|
259
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:write).once.with("Person:/", an_instance_of(String), hash_excluding(:expires_in))
|
239
260
|
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{etag:"1234567890"})))
|
240
261
|
Person.perform_caching true
|
241
262
|
Person.all
|
@@ -264,14 +285,22 @@ describe Flexirest::Caching do
|
|
264
285
|
end
|
265
286
|
end
|
266
287
|
|
267
|
-
it "should write the response to the cache if there's a hard expiry" do
|
288
|
+
it "should write the response to the cache with expires_in option if there's a hard expiry in the future" do
|
268
289
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
269
|
-
expect_any_instance_of(CachingExampleCacheStore5).to receive(:write).once.with("Person:/", an_instance_of(String),
|
290
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:write).once.with("Person:/", an_instance_of(String), hash_including(:expires_in))
|
270
291
|
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{expires:(Time.now + 30).rfc822})))
|
271
292
|
Person.perform_caching = true
|
272
293
|
Person.all
|
273
294
|
end
|
274
295
|
|
296
|
+
it "should not write the response to the cache if there's a hard expiry in the past" do
|
297
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
298
|
+
expect_any_instance_of(CachingExampleCacheStore5).not_to receive(:write)
|
299
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{expires:(Time.now - 10).rfc822})))
|
300
|
+
Person.perform_caching = true
|
301
|
+
Person.all
|
302
|
+
end
|
303
|
+
|
275
304
|
it "should not write the response to the cache if there's an invalid expiry" do
|
276
305
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
277
306
|
expect_any_instance_of(CachingExampleCacheStore5).to_not receive(:write).once.with("Person:/", an_instance_of(String), an_instance_of(Hash))
|
@@ -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
|
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)
|
data/spec/lib/connection_spec.rb
CHANGED
@@ -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
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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,6 +10,9 @@ 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
|
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-15 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
|
- - ">="
|
@@ -184,6 +178,20 @@ dependencies:
|
|
184
178
|
- - ">="
|
185
179
|
- !ruby/object:Gem::Version
|
186
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: timecop
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
187
195
|
- !ruby/object:Gem::Dependency
|
188
196
|
name: mime-types
|
189
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,14 +240,14 @@ dependencies:
|
|
232
240
|
requirements:
|
233
241
|
- - "~>"
|
234
242
|
- !ruby/object:Gem::Version
|
235
|
-
version: '
|
243
|
+
version: '2.7'
|
236
244
|
type: :runtime
|
237
245
|
prerelease: false
|
238
246
|
version_requirements: !ruby/object:Gem::Requirement
|
239
247
|
requirements:
|
240
248
|
- - "~>"
|
241
249
|
- !ruby/object:Gem::Version
|
242
|
-
version: '
|
250
|
+
version: '2.7'
|
243
251
|
- !ruby/object:Gem::Dependency
|
244
252
|
name: activesupport
|
245
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +262,20 @@ dependencies:
|
|
254
262
|
- - ">="
|
255
263
|
- !ruby/object:Gem::Version
|
256
264
|
version: '0'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: actionpack
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
257
279
|
description: Accessing REST services in a flexible way
|
258
280
|
email:
|
259
281
|
- andy@andyjeffries.co.uk
|
@@ -378,14 +400,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
400
|
requirements:
|
379
401
|
- - ">="
|
380
402
|
- !ruby/object:Gem::Version
|
381
|
-
version:
|
403
|
+
version: 3.0.0
|
382
404
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
405
|
requirements:
|
384
406
|
- - ">="
|
385
407
|
- !ruby/object:Gem::Version
|
386
408
|
version: '0'
|
387
409
|
requirements: []
|
388
|
-
rubygems_version: 3.
|
410
|
+
rubygems_version: 3.4.6
|
389
411
|
signing_key:
|
390
412
|
specification_version: 4
|
391
413
|
summary: This gem is for accessing REST services in a flexible way. ActiveResource
|