Skip to content

Commit 1fb277b

Browse files
authored
Merge pull request #4 from Vasfed/rails7_support
Support for rails 7
2 parents 444c2c1 + 57a5b14 commit 1fb277b

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@ jobs:
66

77
strategy:
88
matrix:
9+
# lockfiles are not commited, so autodetection will not work, need to specify bundler version
910
include:
1011
- ruby-version: 2.3.8
1112
rails-version: 3
13+
bundler-version: 1.17.3
1214
- ruby-version: 2.3.8
1315
rails-version: 40
16+
bundler-version: 1.17.3
1417
- ruby-version: 2.3.8
1518
rails-version: 42
19+
bundler-version: 1.17.3
1620

1721
- ruby-version: 2.3.8
1822
rails-version: 50_rspec
23+
bundler-version: default
1924
- ruby-version: 2.6.9
2025
rails-version: 50_simplecov
26+
bundler-version: default
2127
- ruby-version: 2.7.5
2228
rails-version: 6
23-
# - ruby-version: 2.7.5
24-
# rails-version: 70
29+
bundler-version: default
30+
- ruby-version: 3.1.2
31+
rails-version: 7
32+
bundler-version: default
2533

2634
env:
2735
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile
@@ -33,7 +41,7 @@ jobs:
3341
with:
3442
ruby-version: ${{ matrix.ruby-version }}
3543
bundler-cache: true
36-
bundler: '1.17.3'
44+
bundler: ${{ matrix.bundler-version }}
3745

3846
- name: Run tests
3947
run: |

Appraisals

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ else
3838
appraise 'rails-6' do
3939
gem 'rails', '~>6.0.4'
4040
end
41+
42+
appraise 'rails-7' do
43+
gem 'rails', '~>7.0.2'
44+
end
4145
end

gemfiles/rails_7.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "rails", "~>7.0.2"
6+
7+
gemspec path: "../"

lib/routes_coverage/auditor.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def controller_class_by_name(controller_name)
3737
controllers_hash[controller_name] ||= "#{controller_name}_controller".classify.constantize
3838
logger.warn "Controller #{controller_name} was not collected, but exists"
3939
controllers_hash[controller_name]
40+
rescue ArgumentError => e
41+
@missing_controllers << controller_name
42+
logger.warn "Controller #{controller_name} failed to load: #{e}"
43+
nil
4044
rescue NameError
4145
@missing_controllers << controller_name
4246
logger.warn "Controller #{controller_name} looks not existing"

spec/main_spec.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def run_dummy_rspec(testfile = 'dummy_rspec.rb')
105105
end
106106

107107
it "working mounted engines, including Sprockets" do
108-
skip if Rails.version < '4'
108+
skip if Rails.version < '4' || Rails.version >= '7'
109109
res, code = run_dummy_test 'sprockets_test.rb'
110110
assert(code.success?)
111111
assert_match(/Routes coverage is (\d+(.\d+)?)%/, res)
@@ -132,15 +132,23 @@ def run_dummy_rspec(testfile = 'dummy_rspec.rb')
132132
assert_includes(res, "Controller somespace/foo looks not existing")
133133
assert_includes(res, "Controller otherspace/bar looks not existing")
134134
assert_includes(res, "Controller subdomain_route looks not existing")
135-
assert_includes(res, "Missing 6 actions:")
136135

137-
_, missing_actions = res.split("Missing 6 actions:\n", 2)
138-
assert_equal(<<~TXT, missing_actions)
136+
expected_count = 6
137+
expected_output = <<~TXT
139138
dummy: create, except: %i[new create show edit destroy], only: %i[index update] , Missing custom: some_custom, not_found_error
140139
somespace/foo: index, except: %i[index new create show edit update destroy], only: %i[]
141140
otherspace/bar: index, except: %i[index new create show edit update destroy], only: %i[]
142141
subdomain_route: index, except: %i[index new create show edit update destroy], only: %i[]
143142
TXT
143+
144+
if res.include?('Controller rails/welcome failed to load') # rails 7 has bug
145+
expected_count = 7
146+
expected_output += "rails/welcome: index, except: %i[index new create show edit update destroy], only: %i[]\n"
147+
end
148+
149+
assert_includes(res, "Missing #{expected_count} actions:")
150+
_, missing_actions = res.split("Missing #{expected_count} actions:\n", 2)
151+
assert_equal(expected_output, missing_actions)
144152
end
145153

146154
if defined? RSpec

0 commit comments

Comments
 (0)