Skip to content

Commit 9229b64

Browse files
authored
Add rubocop to CI build (#84)
This fixes some existing rubocop violations via the auto-correct mechanism and then adds rubocop to the CI build as an extra step in the "test" job, but only executing for Ruby v3.3 and Rails v7.2 (currently the latest version of each being tested).
2 parents e54cc7a + f47b373 commit 9229b64

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ jobs:
2222
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
2323
steps:
2424
- uses: actions/checkout@v3
25+
2526
- name: Set up Ruby
2627
uses: ruby/setup-ruby@v1
2728
with:
2829
ruby-version: ${{ matrix.ruby-version }}
2930
rubygems: 3.4.10
3031
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
32+
33+
- name: Run linter
34+
if: matrix.ruby-version == '3.3' && matrix.gemfile == 'rails_7.2'
35+
run: bundle exec rubocop
36+
3137
- name: Run tests
3238
run: bundle exec rspec
3339

lib/rpi_auth/spec_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module SpecHelpers
55
# This sets up the OmniAuth mock for the given user. It assumes the User
66
# model has an `:user_id` method which returns the users ID, but this can
77
# be changed by setting the `id_param` option.
8-
def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize
8+
def stub_auth_for(user:, id_param: :user_id)
99
expires_at = user.respond_to?(:expires_at) && user.expires_at
1010
expires_in = expires_at.present? ? expires_at.to_i - Time.zone.now.to_i : 3600
1111
token = user.respond_to?(:access_token) ? user.access_token : SecureRandom.hex(16)

spec/dummy/spec/requests/auth_request_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
expect(response).to redirect_to('/')
266266
end
267267

268-
context 'when the proc resolves to something other than nil' do # rubocop:disable RSpec/NestedGroups
268+
context 'when the proc resolves to something other than nil' do
269269
# We use `current_user` and `request.env` here as they're available
270270
# in the context of the controller. We use `let!` to make sure the
271271
# proc is defined straightaway, rather than later, when `request` and
@@ -283,7 +283,7 @@
283283
end
284284
end
285285

286-
context 'when the proc raises an exception' do # rubocop:disable RSpec/NestedGroups
286+
context 'when the proc raises an exception' do
287287
# We use `current_user` and `request.env` here as they're available
288288
# in the context of the controller. We use `let!` to make sure the
289289
# proc is defined straightaway, rather than later, when `request` and

0 commit comments

Comments
 (0)