Skip to content

Commit da1466a

Browse files
committed
👷 Fixes for old versions of JWT and Faraday
1 parent 5519806 commit da1466a

File tree

6 files changed

+38
-126
lines changed

6 files changed

+38
-126
lines changed

.rubocop_gradual.lock

Lines changed: 18 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,11 @@
3131
[132, 3, 52, "Gemspec/DependencyVersion: Dependency version specification is required.", 3163430777],
3232
[133, 3, 48, "Gemspec/DependencyVersion: Dependency version specification is required.", 425065368]
3333
],
34-
"spec/examples/google_spec.rb:1491180421": [
35-
[9, 3, 5115, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1014001606],
36-
[97, 5, 1016, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3156315524],
37-
[121, 5, 783, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 1916865261]
38-
],
3934
"spec/oauth2/access_token_spec.rb:1576666213": [
4035
[3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/access_token*_spec.rb`.", 1972107547],
41-
[25, 3, 1935, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1152039306],
42-
[42, 5, 915, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1914441490],
43-
[56, 7, 507, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3775341637],
44-
[81, 5, 564, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 935902373],
45-
[145, 7, 371, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 81675473],
46-
[156, 7, 269, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2703574041],
47-
[166, 7, 343, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 571450510],
48-
[177, 7, 1671, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2358061917],
49-
[185, 9, 218, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2937949503],
50-
[193, 9, 1213, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3948450440],
51-
[201, 11, 416, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3896472588],
52-
[206, 13, 238, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 669428729],
53-
[215, 11, 250, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 962614116],
54-
[223, 11, 249, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1923581233],
55-
[471, 5, 968, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 908014549],
56-
[500, 5, 1224, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 2179768666],
5736
[590, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088],
58-
[641, 3, 3135, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 2805647353],
5937
[660, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639],
60-
[664, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967],
61-
[672, 5, 472, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 1289485551],
62-
[702, 5, 346, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 2554883613],
63-
[712, 5, 398, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 2789987624],
64-
[723, 5, 413, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 1645012911],
65-
[734, 5, 263, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 4224752268],
66-
[753, 3, 385, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 293530329]
38+
[664, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967]
6739
],
6840
"spec/oauth2/authenticator_spec.rb:853320290": [
6941
[3, 1, 36, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/authenticator*_spec.rb`.", 819808017],
@@ -72,46 +44,26 @@
7244
[69, 15, 38, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1480816240],
7345
[79, 13, 23, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2314399065]
7446
],
75-
"spec/oauth2/client_spec.rb:4220405778": [
47+
"spec/oauth2/client_spec.rb:3773709445": [
7648
[6, 1, 29, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/client*_spec.rb`.", 439549885],
7749
[174, 7, 492, "RSpec/NoExpectationExample: No expectation found in this example.", 1272021224],
7850
[193, 7, 592, "RSpec/NoExpectationExample: No expectation found in this example.", 3428877205],
7951
[206, 15, 20, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2320605227],
8052
[221, 15, 20, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1276531672],
8153
[236, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1383956904],
8254
[251, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 3376202107],
83-
[472, 7, 241, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1113144453],
84-
[479, 7, 233, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2616254065],
85-
[585, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463],
86-
[594, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621],
87-
[605, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251],
88-
[626, 5, 1711, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 821658737],
89-
[638, 7, 564, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3188010848],
90-
[645, 9, 314, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 2323166106],
91-
[650, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785],
92-
[655, 7, 745, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 2242274228],
93-
[658, 9, 379, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3157074309],
94-
[668, 9, 266, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 165934392],
95-
[679, 5, 2992, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3212702825],
96-
[695, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886],
97-
[699, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529],
98-
[707, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419],
99-
[711, 7, 812, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3531056573],
100-
[719, 9, 505, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 2126944993],
101-
[735, 7, 571, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 2450549440],
102-
[738, 9, 209, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 1769133328],
103-
[746, 9, 262, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [8/5]", 165934392],
104-
[756, 7, 275, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 4192619324],
105-
[764, 7, 377, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1634937780],
106-
[779, 5, 1920, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 3715188517],
107-
[795, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886],
108-
[799, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529],
109-
[807, 7, 298, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2420524519],
110-
[816, 7, 474, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 2129407861],
111-
[828, 7, 357, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [6/5]", 1696484657],
112-
[879, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325],
113-
[904, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076],
114-
[914, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549]
55+
[590, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463],
56+
[599, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621],
57+
[610, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251],
58+
[655, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785],
59+
[700, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886],
60+
[704, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529],
61+
[712, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419],
62+
[800, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886],
63+
[804, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529],
64+
[884, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325],
65+
[909, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076],
66+
[919, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549]
11567
],
11668
"spec/oauth2/error_spec.rb:1209122273": [
11769
[23, 1, 28, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/error*_spec.rb`.", 3385870076],
@@ -127,36 +79,11 @@
12779
[3, 1, 31, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/response*_spec.rb`.", 3190869319],
12880
[317, 33, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785]
12981
],
130-
"spec/oauth2/strategy/assertion_spec.rb:1649395638": [
131-
[6, 1, 42, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/assertion*_spec.rb`.", 3665690869],
132-
[39, 3, 8028, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3790653154],
133-
[59, 5, 3399, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 1213098407],
134-
[68, 7, 475, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3673049530],
135-
[83, 7, 511, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 1482428850],
136-
[94, 9, 174, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 509043384],
137-
[101, 7, 626, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 1073364157],
138-
[112, 9, 276, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [12/5]", 3402508104],
139-
[121, 7, 1463, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [11/5]", 631415582],
140-
[124, 9, 431, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [11/5]", 1333000403],
141-
[134, 9, 268, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [11/5]", 4208916299],
142-
[142, 9, 312, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [11/5]", 4006695562],
143-
[152, 9, 300, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [11/5]", 504386954],
144-
[164, 5, 2485, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3985973933],
145-
[165, 7, 1368, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 975431363],
146-
[190, 7, 1057, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 2712213015],
147-
[212, 5, 1639, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 325089515],
148-
[217, 9, 1383, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 2493875547],
149-
[246, 11, 260, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 3397767518],
150-
[254, 11, 223, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [9/5]", 242220550]
82+
"spec/oauth2/strategy/assertion_spec.rb:2269367634": [
83+
[6, 1, 42, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/assertion*_spec.rb`.", 3665690869]
15184
],
15285
"spec/oauth2/strategy/auth_code_spec.rb:142083698": [
153-
[4, 1, 41, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/auth_code*_spec.rb`.", 1553708922],
154-
[4, 1, 5753, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 833437399],
155-
[48, 3, 919, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3083983110],
156-
[75, 3, 522, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 1383502446],
157-
[94, 3, 672, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3159970527],
158-
[119, 3, 372, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 3139680688],
159-
[131, 7, 986, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [7/5]", 2685471594]
86+
[4, 1, 41, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/auth_code*_spec.rb`.", 1553708922]
16087
],
16188
"spec/oauth2/strategy/base_spec.rb:2524881749": [
16289
[3, 1, 37, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/base*_spec.rb`.", 1951594922]
@@ -170,7 +97,7 @@
17097
"spec/oauth2/strategy/password_spec.rb:331601826": [
17198
[3, 1, 41, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/strategy/password*_spec.rb`.", 3463323840]
17299
],
173-
"spec/oauth2/version_spec.rb:2895330438": [
100+
"spec/oauth2/version_spec.rb:1001406821": [
174101
[3, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/version*_spec.rb`.", 1099517182]
175102
],
176103
"spec/oauth2_spec.rb:1511642301": [

.rubocop_rspec.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ RSpec/DescribeClass:
2626
Exclude:
2727
- 'spec/examples/*'
2828

29+
RSpec/MultipleMemoizedHelpers:
30+
Enabled: false

spec/oauth2/client_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,13 @@
334334
{scope: "email profile"}
335335
end
336336

337+
# This doesn't happen on Faraday v0, since it isn't an option until Faraday v1.0.0
337338
it "encoded as %20" do
338-
expect(subject).to include "email%20profile"
339+
if Faraday::VERSION >= "1.0.0"
340+
expect(subject).to include "email%20profile"
341+
else
342+
expect(subject).to include "email+profile"
343+
end
339344
end
340345
end
341346
end

spec/oauth2/strategy/assertion_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@
127127

128128
it "raises JWT::EncodeError" do
129129
# this behavior is handled by the JWT gem, but this should make sure it is consistent
130-
expect { client_assertion.get_token(claims, encoding_opts) }.to raise_error(JWT::EncodeError, "Unsupported signing method")
130+
# On old Ruby (versions 2.4 and below) the error raised was different because
131+
# a very old version of the jwt gem gets installed.
132+
if VersionGem::Ruby.gte_minimum_version?("2.5")
133+
expect { client_assertion.get_token(claims, encoding_opts) }.to raise_error(JWT::EncodeError, "Unsupported signing method")
134+
else
135+
expect { client_assertion.get_token(claims, encoding_opts) }.to raise_error(NotImplementedError)
136+
end
131137
end
132138
end
133139

spec/oauth2/version_spec.rb

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
11
# frozen_string_literal: true
22

33
RSpec.describe OAuth2::Version do
4-
it "has a version number" do
5-
expect(described_class).not_to be_nil
6-
end
7-
8-
it "can be a string" do
9-
expect(described_class.to_s).to be_a(String)
10-
end
11-
12-
it "allows Constant access" do
13-
expect(described_class::VERSION).to be_a(String)
14-
end
15-
16-
it "is greater than 0.1.0" do
17-
expect(Gem::Version.new(described_class) > Gem::Version.new("0.1.0")).to be(true)
18-
end
19-
20-
it "major version is an integer" do
21-
expect(described_class.major).to be_a(Integer)
22-
end
23-
24-
it "minor version is an integer" do
25-
expect(described_class.minor).to be_a(Integer)
26-
end
27-
28-
it "patch version is an integer" do
29-
expect(described_class.patch).to be_a(Integer)
30-
end
31-
32-
it "returns a Hash" do
33-
expect(described_class.to_h.keys).to match_array(%i[major minor patch pre])
34-
end
4+
it_behaves_like "a Version module", described_class
355

36-
it "returns an Array" do
37-
expect(described_class.to_a).to be_a(Array)
6+
it "is greater than 1.0.0" do
7+
expect(Gem::Version.new(described_class) >= Gem::Version.new("1.0.0")).to(be(true))
388
end
399
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
require "addressable/uri"
1010
require "rspec/pending_for"
1111
require "rspec/block_is_expected"
12+
require "version_gem/ruby"
13+
require "version_gem/rspec"
1214

1315
# Extensions
1416
require_relative "ext/backports"

0 commit comments

Comments
 (0)