rubocop-asjer 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77e721d22becd80eb1bbaccc3500469cd8212a4da6c7fd11f44a09cabe8aeb8
4
- data.tar.gz: f5d7b66942be7be87b03f40c77e6464580634bac15962c78472f570cf1c836f8
3
+ metadata.gz: 33824991e93fac5f0a6dc2ac7170e29f1f19ced20457f9ce1e3ce65fe1fb2073
4
+ data.tar.gz: 360f3e9dd1884e3f59325d639771ab7204c35a86fdb2ced78eadf14333d70dda
5
5
  SHA512:
6
- metadata.gz: 3fe9c2037c36e265dfb0a175caef40d1132dc4c0eb50b8e70cd47d3cc4b8479196e32eab6ef46f5ed408c0909de1c2f74f52979da414eab3900384b10917503a
7
- data.tar.gz: 0357f2dfb8e2495a44a756f93e80654a7f0533d085b3e814ba6de18cb80912b1b23689e6e7bdea96a319d620fcf73ad71b8f1ec1763c46a1b0848d85150b33d2
6
+ metadata.gz: 81cb50c70f94b0a6ef221022971961b8939519f786e492a926e7fb5dff0b49dabad85c9f8ac9fd8490e55f68af32136667238b438679f4e0440c006279729398
7
+ data.tar.gz: fcd0440e6123b3f3e871de30276b62eea4bcd80e466f829e1ee97b49f6c6668ba709cc353aefb2045fc3260a111b88e501c821affae1d21f3092b40261aef964
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.5.0"
2
+ ".": "0.6.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0](https://github.com/asjer/rubocop-asjer/compare/v0.5.0...v0.6.0) (2026-10-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * **cop:** flag bare login_as calls in system specs ([c4d99a4](https://github.com/asjer/rubocop-asjer/commit/c4d99a42f25072bfc55f5b381c3fe89ff303e391))
9
+
3
10
  ## [0.5.0](https://github.com/asjer/rubocop-asjer/compare/v0.4.5...v0.5.0) (2026-10-15)
4
11
 
5
12
 
data/README.md CHANGED
@@ -161,6 +161,41 @@ migration_context.migrate(20261012170000)
161
161
 
162
162
  By default, this cop runs on `spec/migrations/**/*_spec.rb`.
163
163
 
164
+ ### Asjer/SystemSpecLoginAs
165
+
166
+ Requires unqualified `login_as` calls in system specs to be replaced with an application-provided helper such as `sign_in_and_visit(user, path)`. Warden's handoff applies to whichever request reaches the app server next, not necessarily the browser's intended visit.
167
+
168
+ Every matching call is reported, including calls in `before` blocks, whether a `visit` follows immediately, later, or not at all. Calls with an explicit receiver, such as `foo.login_as(user)`, are outside this cop's scope.
169
+
170
+ ```ruby
171
+ # bad
172
+ login_as(user)
173
+ visit dashboard_path
174
+
175
+ before do
176
+ login_as(user)
177
+ end
178
+
179
+ # good
180
+ sign_in_and_visit(user, dashboard_path)
181
+ ```
182
+
183
+ By default, this cop only runs on `spec/system/**/*.rb` and is `Enabled: pending`. Opt in explicitly (or enable new cops with `AllCops/NewCops: enable`):
184
+
185
+ ```yaml
186
+ Asjer/SystemSpecLoginAs:
187
+ Enabled: true
188
+ Include:
189
+ - 'spec/system/**/*.rb'
190
+ MethodNames:
191
+ - login_as
192
+ PreferredHelper: sign_in_and_visit
193
+ ```
194
+
195
+ `MethodNames` replaces the default list of methods to flag; `PreferredHelper` changes the helper named in the offense message. Define that helper in your application's system-spec support; this gem does not provide it.
196
+
197
+ **No autocorrect:** the cop cannot infer the destination path or safely move authentication out of a `before` block.
198
+
164
199
  ## Development
165
200
 
166
201
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests.
data/config/default.yml CHANGED
@@ -165,3 +165,13 @@ Asjer/RailsClassOrder:
165
165
  - has_secure_token
166
166
  - generates_token_for
167
167
  - composed_of
168
+
169
+ Asjer/SystemSpecLoginAs:
170
+ Description: Requires system specs to use a helper that signs in and visits together instead of a bare Warden handoff.
171
+ Enabled: pending
172
+ VersionAdded: "0.6.0"
173
+ Include:
174
+ - 'spec/system/**/*.rb'
175
+ MethodNames:
176
+ - login_as
177
+ PreferredHelper: sign_in_and_visit
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Asjer
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
data/lib/rubocop/asjer.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'cop/asjer/no_default_translation'
8
8
  require_relative 'cop/asjer/explicit_migration_version_in_spec'
9
9
  require_relative 'cop/asjer/migration_schema_only'
10
10
  require_relative 'cop/asjer/rails_class_order'
11
+ require_relative 'cop/asjer/system_spec_login_as'
11
12
 
12
13
  module RuboCop
13
14
  module Asjer
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Asjer
6
+ # Requires system specs to use a helper that signs in and visits together.
7
+ #
8
+ # Warden's handoff applies to the next request reaching the app server,
9
+ # which need not be the browser's intended visit. The application must
10
+ # provide the replacement helper.
11
+ #
12
+ # @example
13
+ # # bad
14
+ # login_as(user)
15
+ # visit dashboard_path
16
+ #
17
+ # # good
18
+ # sign_in_and_visit(user, dashboard_path)
19
+ #
20
+ class SystemSpecLoginAs < Base
21
+ MSG = 'Use `%<helper>s` instead of `%<method>s` in system specs: ' \
22
+ 'the Warden handoff applies to whichever request reaches the app server next, ' \
23
+ "not necessarily the browser's visit."
24
+
25
+ def on_send(node)
26
+ return unless node.receiver.nil?
27
+ return unless cop_config.fetch('MethodNames', ['login_as']).include?(node.method_name.to_s)
28
+
29
+ helper = cop_config.fetch('PreferredHelper', 'sign_in_and_visit')
30
+ add_offense(node.loc.selector, message: format(MSG, helper: helper, method: node.method_name))
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-asjer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asjer Querido
@@ -60,6 +60,7 @@ files:
60
60
  - lib/rubocop/cop/asjer/migration_schema_only.rb
61
61
  - lib/rubocop/cop/asjer/no_default_translation.rb
62
62
  - lib/rubocop/cop/asjer/rails_class_order.rb
63
+ - lib/rubocop/cop/asjer/system_spec_login_as.rb
63
64
  - mise.toml
64
65
  - release-please-config.json
65
66
  - sig/rubocop/i18n.rbs