Skip to content

Commit bde8b9b

Browse files
authored
Rails 7 compatibility; fix CI pipeline (#124)
* Fix deprecated use of ActiveSupport::Deprecation singleton instance * Fix and update .rubocop_todo.yml * Fix specs by matching header names case-insensitively * Update changelog
1 parent bedc9f3 commit bde8b9b

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

.rubocop_todo.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-04-06 14:14:58 UTC using RuboCop version 1.62.1.
3+
# on 2024-09-11 20:09:03 UTC using RuboCop version 1.66.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -49,6 +49,7 @@ Metrics/BlockLength:
4949
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
5050
Naming/FileName:
5151
Exclude:
52+
- 'Rakefile.rb'
5253
- 'lib/grape-swagger-rails.rb'
5354
- 'spec/features/grape-swagger-rails_spec.rb'
5455

@@ -61,7 +62,7 @@ RSpec/ContextWording:
6162

6263
# Offense count: 1
6364
# This cop supports unsafe autocorrection (--autocorrect-all).
64-
# Configuration parameters: SkipBlocks, EnforcedStyle.
65+
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
6566
# SupportedStyles: described_class, explicit
6667
RSpec/DescribedClass:
6768
Exclude:
@@ -72,13 +73,6 @@ RSpec/DescribedClass:
7273
RSpec/ExampleLength:
7374
Max: 8
7475

75-
# Offense count: 1
76-
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
77-
# Include: **/*_spec*rb*, **/spec/**/*
78-
RSpec/FilePath:
79-
Exclude:
80-
- 'spec/features/grape-swagger-rails_spec.rb'
81-
8276
# Offense count: 2
8377
# Configuration parameters: AssignmentOnly.
8478
RSpec/InstanceVariable:
@@ -124,9 +118,9 @@ Style/OpenStructUse:
124118
Exclude:
125119
- 'lib/grape-swagger-rails.rb'
126120

127-
# Offense count: 2
121+
# Offense count: 1
128122
# This cop supports safe autocorrection (--autocorrect).
129123
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
130124
# URISchemes: http, https
131125
Layout/LineLength:
132-
Max: 143
126+
Max: 124

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
### 0.5.1 (Next)
22

3+
* [#124](https://github.com/ruby-grape/grape-swagger-rails/pull/124): Rails 7 compatibility - [@padde](https://github.com/padde).
34
* Your contribution here.
4-
5+
56
### 0.5.0 (2024/04/06)
67

78
* [#110](https://github.com/ruby-grape/grape-swagger-rails/pull/110): Update dummy app to current rails conventions - [@duffn](https://github.com/duffn).

lib/grape-swagger-rails.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
module GrapeSwaggerRails
77
class Options < OpenStruct
88
def before_filter(&block)
9-
ActiveSupport::Deprecation.warn('This option is deprecated and going to be removed in 1.0.0. ' \
10-
'Please use `before_action` instead')
9+
GrapeSwaggerRails.deprecator.warn(
10+
'This option is deprecated and going to be removed in 1.0.0. ' \
11+
'Please use `before_action` instead'
12+
)
1113
before_action(&block)
1214
end
1315

@@ -43,4 +45,8 @@ def before_action(&block)
4345
hide_url_input: false,
4446
hide_api_key_input: false
4547
)
48+
49+
def self.deprecator
50+
@deprecator ||= ActiveSupport::Deprecation.new('1.0', 'GrapeSwaggerRails')
51+
end
4652
end

spec/features/swagger_spec.rb

+11-9
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
find_by_id('endpointListTogger_headers', visible: true).click
5252
first('span[class="http_method"] a', visible: true).click
5353
click_button 'Try it out!'
54-
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
54+
expect(page).to have_css 'span.hljs-attr', text: /X-Test-Header/i
5555
expect(page).to have_css 'span.hljs-string', text: 'Test Value'
5656
end
5757

5858
it 'supports multiple headers' do
5959
find_by_id('endpointListTogger_headers', visible: true).click
6060
first('span[class="http_method"] a', visible: true).click
6161
click_button 'Try it out!'
62-
expect(page).to have_css 'span.hljs-attr', text: 'X-Test-Header'
62+
expect(page).to have_css 'span.hljs-attr', text: /X-Test-Header/i
6363
expect(page).to have_css 'span.hljs-string', text: 'Test Value'
64-
expect(page).to have_css 'span.hljs-attr', text: 'X-Another-Header'
64+
expect(page).to have_css 'span.hljs-attr', text: /X-Another-Header/i
6565
expect(page).to have_css 'span.hljs-string', text: 'Another Value'
6666
end
6767
end
@@ -108,7 +108,7 @@
108108
find_by_id('endpointListTogger_headers', visible: true).click
109109
first('span[class="http_method"] a', visible: true).click
110110
click_button 'Try it out!'
111-
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
111+
expect(page).to have_css 'span.hljs-attr', text: /Authorization/i
112112
expect(page).to have_css 'span.hljs-string', text: "Basic #{Base64.encode64('username:password').strip}"
113113
end
114114
end
@@ -127,7 +127,7 @@
127127
find_by_id('endpointListTogger_headers', visible: true).click
128128
first('span[class="http_method"] a', visible: true).click
129129
click_button 'Try it out!'
130-
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
130+
expect(page).to have_css 'span.hljs-attr', text: /Authorization/i
131131
expect(page).to have_css 'span.hljs-string', text: 'Bearer token'
132132
end
133133
end
@@ -146,7 +146,7 @@
146146
find_by_id('endpointListTogger_headers', visible: true).click
147147
first('span[class="http_method"] a', visible: true).click
148148
click_button 'Try it out!'
149-
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
149+
expect(page).to have_css 'span.hljs-attr', text: /Authorization/i
150150
expect(page).to have_css 'span.hljs-string', text: 'Token token'
151151
end
152152
end
@@ -171,14 +171,16 @@
171171

172172
describe '#before_filter' do
173173
before do
174-
allow(ActiveSupport::Deprecation).to receive(:warn)
174+
allow(GrapeSwaggerRails.deprecator).to receive(:warn)
175175
end
176176

177177
it 'throws deprecation warning' do
178178
GrapeSwaggerRails.options.before_filter { true }
179179

180-
expect(ActiveSupport::Deprecation).to have_received(:warn).with('This option is deprecated ' \
181-
'and going to be removed in 1.0.0. Please use `before_action` instead')
180+
expect(GrapeSwaggerRails.deprecator).to have_received(:warn).with(
181+
'This option is deprecated and going to be removed in 1.0.0. ' \
182+
'Please use `before_action` instead'
183+
)
182184
end
183185
end
184186

0 commit comments

Comments
 (0)