radius-spec 0.6.0 → 0.10.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 +4 -4
- data/.github/workflows/ci.yml +28 -0
- data/.github/workflows/reviewdog.yml +21 -0
- data/.rubocop.yml +7 -7
- data/CHANGELOG.md +124 -0
- data/Gemfile +1 -3
- data/README.md +5 -6
- data/benchmarks/call_vs_yield.rb +0 -2
- data/benchmarks/cover_vs_include.rb +2 -2
- data/benchmarks/format_string.rb +3 -3
- data/benchmarks/hash_each.rb +305 -0
- data/benchmarks/hash_merge.rb +1 -1
- data/benchmarks/hash_transform.rb +455 -0
- data/benchmarks/style_hash_like_case.rb +285 -0
- data/benchmarks/unfreeze_string.rb +0 -2
- data/bin/bundle +114 -0
- data/common_rubocop.yml +144 -49
- data/common_rubocop_rails.yml +82 -16
- data/lib/radius/spec/model_factory.rb +9 -2
- data/lib/radius/spec/rspec.rb +9 -0
- data/lib/radius/spec/vcr.rb +0 -2
- data/lib/radius/spec/version.rb +1 -1
- data/radius-spec.gemspec +8 -7
- metadata +39 -15
- data/.travis.yml +0 -14
- data/bin/ci-code-review +0 -28
data/common_rubocop.yml
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.7.0
|
3
|
+
# We choose to opt-in to new checks by default. This allows us to update
|
4
|
+
# version by version without having to worry about adding an entry for each
|
5
|
+
# new "enabled by default" check. If we want to jump multiple versions and
|
6
|
+
# wish to be notified of all the enw check, then we'll need to change
|
7
|
+
# `NewCops` to `pending`.
|
8
|
+
NewCops: enable
|
3
9
|
Exclude:
|
4
10
|
# Exclude generated binstubs
|
5
11
|
- 'bin/bundle'
|
@@ -56,7 +62,7 @@ Layout/AccessModifierIndentation:
|
|
56
62
|
# SupportedHashRocketStyles: key, separator, table
|
57
63
|
# SupportedColonStyles: key, separator, table
|
58
64
|
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
59
|
-
Layout/
|
65
|
+
Layout/HashAlignment:
|
60
66
|
Enabled: true
|
61
67
|
EnforcedHashRocketStyle: key
|
62
68
|
EnforcedColonStyle: key
|
@@ -79,17 +85,46 @@ Layout/BlockAlignment:
|
|
79
85
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
80
86
|
# SupportedStyles: consistent, consistent_relative_to_receiver,
|
81
87
|
# special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
82
|
-
|
88
|
+
#
|
89
|
+
# TODO: At some point this is split into both Layout/FirstArgumentIndentation
|
90
|
+
# and Layout/FirstParameterIndentation
|
91
|
+
Layout/FirstArgumentIndentation:
|
83
92
|
Enabled: false
|
84
93
|
|
85
|
-
#
|
86
|
-
#
|
87
|
-
# alternatives; even for Rails app.
|
94
|
+
# We generally prefer to use the default line length of 80. Though sometimes
|
95
|
+
# we just need a little extra space because it makes it easier to read.
|
88
96
|
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
92
|
-
|
97
|
+
# The only way to disable Rubocop for a single line is either to wrap the line
|
98
|
+
# with two comments or append the disable comment to the end of the line. For
|
99
|
+
# guard clauses, we tend to prefer trailing comments to avoid adding two lines
|
100
|
+
# just to disable a cop on one line.
|
101
|
+
#
|
102
|
+
# Sometimes comments include ASCII diagrams, flow charts, etc. These cannot
|
103
|
+
# always be reformatted to fit within the 80 column limit. Also, we write most
|
104
|
+
# comments in markdown format. Rubocop isn't very good at understanding when
|
105
|
+
# the line is long because of a URL in a markdown link. Instead of requiring
|
106
|
+
# additional comments to turn this cop off for comments we ignore any long
|
107
|
+
# lines which are only comments.
|
108
|
+
#
|
109
|
+
# There are also cases where for one valid reason or another we have a trailing
|
110
|
+
# comment that extends a little too far. We'd like to be able to ignore those
|
111
|
+
# as well. This _attempts_ to do that, however, as this uses simple regular
|
112
|
+
# expressions we can only attempt to match so much. We probably should change
|
113
|
+
# this for a node pattern matcher in the future.
|
114
|
+
#
|
115
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
|
116
|
+
# IgnoreCopDirectives, IgnoredPatterns.
|
117
|
+
# URISchemes: http, https
|
118
|
+
Layout/LineLength:
|
119
|
+
IgnoreCopDirectives: true
|
120
|
+
IgnoredPatterns:
|
121
|
+
# Leading comments
|
122
|
+
- '\A\s*#'
|
123
|
+
# Attempt at trailing comments
|
124
|
+
- '\A.{1,78}\s#\s.*\z'
|
125
|
+
Max: 100
|
126
|
+
Exclude:
|
127
|
+
- '**/*.gemspec'
|
93
128
|
|
94
129
|
# We tend to indent multi-line operation statements. I think this is because it
|
95
130
|
# tends to be the default style auto-formatted by VIM (which many of us use).
|
@@ -124,6 +159,31 @@ Lint/AmbiguousBlockAssociation:
|
|
124
159
|
Exclude:
|
125
160
|
- 'spec/**/*_spec.rb'
|
126
161
|
|
162
|
+
# We prefer to enforce a consistent usage for readability
|
163
|
+
#
|
164
|
+
# <<~SQL.strip
|
165
|
+
# bar
|
166
|
+
# SQL
|
167
|
+
#
|
168
|
+
# display(<<~SQL.strip)
|
169
|
+
# bar
|
170
|
+
# SQL
|
171
|
+
#
|
172
|
+
# Alternatively, refactoring the heredoc into a local also improves
|
173
|
+
# readability:
|
174
|
+
#
|
175
|
+
# custom_sql = <<~SQL
|
176
|
+
# bar
|
177
|
+
# SQL
|
178
|
+
# display(custom_sql.strip)
|
179
|
+
Lint/HeredocMethodCallPosition:
|
180
|
+
Enabled: true
|
181
|
+
|
182
|
+
# We prefer people suggesting people subclass `StandardError` for their custom
|
183
|
+
# exceptions as this is a relatively common Ruby idiom.
|
184
|
+
Lint/InheritException:
|
185
|
+
EnforcedStyle: standard_error
|
186
|
+
|
127
187
|
# Often with benchmarking we don't explicitly "use" a variable or return value.
|
128
188
|
# We simply need to perform the operation which generates said value for the
|
129
189
|
# benchmark.
|
@@ -133,9 +193,22 @@ Lint/Void:
|
|
133
193
|
Exclude:
|
134
194
|
- 'benchmarks/**/*'
|
135
195
|
|
196
|
+
Metrics/AbcSize:
|
197
|
+
# TODO: When we are able to upgrade to Rubocop 1.5.0 we want to enable the
|
198
|
+
# following `CountRepeatedAttributes` option. We often find the
|
199
|
+
# multi-references to the same object to be necessary for reability and that
|
200
|
+
# for our team it does not increase complexity.
|
201
|
+
#
|
202
|
+
# CountRepeatedAttributes: false
|
203
|
+
Max: 17
|
204
|
+
|
136
205
|
# Configuration parameters: CountComments, ExcludedMethods, Max.
|
137
206
|
# ExcludedMethods: refine
|
138
207
|
Metrics/BlockLength:
|
208
|
+
CountAsOne:
|
209
|
+
- 'array'
|
210
|
+
- 'hash'
|
211
|
+
- 'heredoc'
|
139
212
|
Exclude:
|
140
213
|
- '**/Rakefile'
|
141
214
|
- '**/*.rake'
|
@@ -144,46 +217,36 @@ Metrics/BlockLength:
|
|
144
217
|
- 'spec/support/model_factories.rb'
|
145
218
|
ExcludedMethods:
|
146
219
|
- 'chdir'
|
220
|
+
- 'describe'
|
147
221
|
- 'refine'
|
222
|
+
- 'shared_context'
|
223
|
+
- 'shared_examples'
|
148
224
|
- 'Capybara.register_driver'
|
149
|
-
- 'Gem::Specification.new'
|
150
225
|
- 'RSpec.configure'
|
226
|
+
- 'RSpec.describe'
|
227
|
+
- 'RSpec.shared_context'
|
228
|
+
- 'RSpec.shared_examples'
|
151
229
|
- 'VCR.configure'
|
152
230
|
|
153
|
-
# We
|
154
|
-
#
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
# this for a node pattern matcher in the future.
|
173
|
-
#
|
174
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
|
175
|
-
# IgnoreCopDirectives, IgnoredPatterns.
|
176
|
-
# URISchemes: http, https
|
177
|
-
Metrics/LineLength:
|
178
|
-
IgnoreCopDirectives: true
|
179
|
-
IgnoredPatterns:
|
180
|
-
# Leading comments
|
181
|
-
- '\A\s*#'
|
182
|
-
# Attempt at trailing comments
|
183
|
-
- '\A.{1,78}\s#\s.*\z'
|
184
|
-
Max: 100
|
185
|
-
Exclude:
|
186
|
-
- '**/*.gemspec'
|
231
|
+
# We want length related code metrics to count Hashs, Arrays, and
|
232
|
+
# Heredocs as one "line"
|
233
|
+
Metrics/ClassLength:
|
234
|
+
CountAsOne:
|
235
|
+
- 'array'
|
236
|
+
- 'hash'
|
237
|
+
- 'heredoc'
|
238
|
+
|
239
|
+
Metrics/ModuleLength:
|
240
|
+
CountAsOne:
|
241
|
+
- 'array'
|
242
|
+
- 'hash'
|
243
|
+
- 'heredoc'
|
244
|
+
|
245
|
+
Metrics/MethodLength:
|
246
|
+
CountAsOne:
|
247
|
+
- 'array'
|
248
|
+
- 'hash'
|
249
|
+
- 'heredoc'
|
187
250
|
|
188
251
|
# This is overly pedantic (only allowing `other` as the parameter name). Ruby
|
189
252
|
# core doesn't follow this consistently either. Looking at several classes
|
@@ -206,14 +269,14 @@ Naming/FileName:
|
|
206
269
|
# `EOF` is a common terminal abbreviate indicating end-of-file. We allow this
|
207
270
|
# for those heredocs which represent "file" text.
|
208
271
|
#
|
209
|
-
# Configuration parameters:
|
210
|
-
#
|
272
|
+
# Configuration parameters: ForbiddenDelimiters.
|
273
|
+
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
211
274
|
Naming/HeredocDelimiterNaming:
|
212
275
|
Details: |
|
213
276
|
|
214
277
|
Use meaningful delimiter names to provide context to the text. The only
|
215
278
|
allowed `EO*` variant if `EOF` which has specific meaning for file content.
|
216
|
-
|
279
|
+
ForbiddenDelimiters:
|
217
280
|
- !ruby/regexp '/(^|\s)(EO[A-EG-Z]{1}|END)(\s|$)/'
|
218
281
|
|
219
282
|
# It is generally a good idea to match the instance variable names with their
|
@@ -235,6 +298,13 @@ Naming/MemoizedInstanceVariableName:
|
|
235
298
|
acceptable.
|
236
299
|
EnforcedStyleForLeadingUnderscores: optional
|
237
300
|
|
301
|
+
# We don't really care about this check. Sometimes using something simple such
|
302
|
+
# as `err` is just fine. Other times it may improve readability to have a more
|
303
|
+
# descriptive name. We feel this is a personal judgement call and not something
|
304
|
+
# that needs to be enforced.
|
305
|
+
Naming/RescuedExceptionsVariableName:
|
306
|
+
Enabled: false
|
307
|
+
|
238
308
|
# `alias` behavior changes on scope. In general we expect the behavior to be
|
239
309
|
# that which is defined by `alias_method`.
|
240
310
|
#
|
@@ -284,7 +354,10 @@ Style/AsciiComments:
|
|
284
354
|
# - Prefer `{...}` over `do...end` for functional blocks.
|
285
355
|
#
|
286
356
|
# When the return value of the method receiving the block is important prefer
|
287
|
-
# `{
|
357
|
+
# `{...}` over `do...end`.
|
358
|
+
#
|
359
|
+
# Some people enjoy the compact readability of `{...}` for one-liners so we
|
360
|
+
# allow that style as well.
|
288
361
|
#
|
289
362
|
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
290
363
|
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
@@ -297,6 +370,7 @@ Style/BlockDelimiters:
|
|
297
370
|
|
298
371
|
When the return value of the method receiving the block is important prefer
|
299
372
|
`{..}` over `do..end`.
|
373
|
+
AllowBracesOnProceduralOneLiners: true
|
300
374
|
Enabled: true
|
301
375
|
EnforcedStyle: semantic
|
302
376
|
ProceduralMethods:
|
@@ -327,6 +401,15 @@ Style/BlockDelimiters:
|
|
327
401
|
- proc
|
328
402
|
- it
|
329
403
|
|
404
|
+
# As a team we prefer the more explicit `def self.method_name` style. We find
|
405
|
+
# the explicitness easier to read and grep for on the CLI.
|
406
|
+
#
|
407
|
+
# Configuration parameters: EnforcedStyle.
|
408
|
+
# SupportedStyles: def_self, self_class
|
409
|
+
Style/ClassMethodsDefinitions:
|
410
|
+
Enabled: true
|
411
|
+
EnforcedStyle: def_self
|
412
|
+
|
330
413
|
# Prefer `Time` over `DateTime`.
|
331
414
|
#
|
332
415
|
# While these are not necessarily interchangeable we prefer `Time`. According
|
@@ -401,6 +484,13 @@ Style/EmptyCaseCondition:
|
|
401
484
|
Style/EmptyMethod:
|
402
485
|
EnforcedStyle: expanded
|
403
486
|
|
487
|
+
# Always require the pragma comment to be true
|
488
|
+
#
|
489
|
+
# Configuration parameters: EnforcedStyle.
|
490
|
+
# SupportedStyles: always, always_true, never
|
491
|
+
Style/FrozenStringLiteralComment:
|
492
|
+
EnforcedStyle: always_true
|
493
|
+
|
404
494
|
# Prefer symbol keys using the 1.9 hash syntax. However, when keys are mixed
|
405
495
|
# use a consistent mapping style; which generally means using hash rockets:
|
406
496
|
#
|
@@ -574,6 +664,11 @@ Style/RescueStandardError:
|
|
574
664
|
Avoid rescuing `Exception` as this may hide system errors.
|
575
665
|
EnforcedStyle: implicit
|
576
666
|
|
667
|
+
# We don't really care which style we use here and would prefer rubocop not
|
668
|
+
# complain about this.
|
669
|
+
Style/SlicingWithRange:
|
670
|
+
Enabled: false
|
671
|
+
|
577
672
|
# We generally prefer double quotes but many generators use single quotes. We
|
578
673
|
# don't view the performance difference to be all that much so we don't care
|
579
674
|
# if the style is mixed or double quotes are used for static strings.
|
data/common_rubocop_rails.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require: rubocop-rails
|
2
|
+
|
1
3
|
inherit_mode:
|
2
4
|
merge:
|
3
5
|
- Exclude
|
@@ -5,10 +7,6 @@ inherit_mode:
|
|
5
7
|
|
6
8
|
inherit_from: common_rubocop.yml
|
7
9
|
|
8
|
-
# Enable additional Rails cops
|
9
|
-
Rails:
|
10
|
-
Enabled: true
|
11
|
-
|
12
10
|
AllCops:
|
13
11
|
Exclude:
|
14
12
|
- 'bin/puma'
|
@@ -22,26 +20,26 @@ AllCops:
|
|
22
20
|
- 'db/migrate/**/*'
|
23
21
|
|
24
22
|
# Rails project's are not concerned with API docs normally
|
25
|
-
Documentation:
|
23
|
+
Style/Documentation:
|
26
24
|
Enabled: false
|
27
25
|
|
28
|
-
Metrics/BlockLength:
|
29
|
-
Exclude:
|
30
|
-
- 'bin/setup'
|
31
|
-
- 'bin/update'
|
32
|
-
- 'config/routes.rb'
|
33
|
-
- 'spec/rails_helper.rb'
|
34
|
-
|
35
26
|
# Rails foreign keys and indexes can get long. We want to ignore our annotation
|
36
27
|
# comments which are for these entries.
|
37
28
|
#
|
38
29
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
39
30
|
# URISchemes: http, https
|
40
|
-
|
31
|
+
Layout/LineLength:
|
41
32
|
IgnoredPatterns:
|
42
33
|
- '\A# fk_rails_'
|
43
34
|
- '\A# index_'
|
44
35
|
|
36
|
+
Metrics/BlockLength:
|
37
|
+
Exclude:
|
38
|
+
- 'bin/setup'
|
39
|
+
- 'bin/update'
|
40
|
+
- 'config/routes.rb'
|
41
|
+
- 'spec/rails_helper.rb'
|
42
|
+
|
45
43
|
# For our Rails apps several of them use the `respond_to` with `format` blocks
|
46
44
|
# to handle various mime types (mostly HTML and JSON). Given our `do` / `end`
|
47
45
|
# block style for non-functional blocks (which includes both `respond_to` and
|
@@ -108,6 +106,11 @@ Rails/ApplicationRecord:
|
|
108
106
|
Rails/CreateTableWithTimestamps:
|
109
107
|
Enabled: false
|
110
108
|
|
109
|
+
# This cop looks for uses of default_scope because named scopes are preferred:
|
110
|
+
# https://rails.rubystyle.guide/#named-scopes
|
111
|
+
Rails/DefaultScope:
|
112
|
+
Enabled: true
|
113
|
+
|
111
114
|
# Usage of `find_by` is more expressive of intent than `where.first`. We should
|
112
115
|
# check all app code, not just the models to improve intent expression.
|
113
116
|
#
|
@@ -121,6 +124,11 @@ Rails/FindBy:
|
|
121
124
|
- 'app/**/*.rb'
|
122
125
|
- 'lib/**/*.rb'
|
123
126
|
|
127
|
+
# This cop enforces that ActiveRecord#find is used instead of where.take!, find_by!, and find_by_id!
|
128
|
+
# to retrieve a single record by primary key when you expect it to be found.
|
129
|
+
Rails/FindById:
|
130
|
+
Enabled: true
|
131
|
+
|
124
132
|
# Usage of `each` for large datasets can be a performance issue; specially a
|
125
133
|
# drain on system memory. When possible it's better to use `find_each` so that
|
126
134
|
# chunks of data are evaluated at a time.
|
@@ -145,6 +153,52 @@ Rails/FindEach:
|
|
145
153
|
Rails/HasAndBelongsToMany:
|
146
154
|
Enabled: false
|
147
155
|
|
156
|
+
# We find the combo `:only` and `:if` readable. While the `:except` and `:if`
|
157
|
+
# combo is easier to read as a combined proc. As a team we are fine with
|
158
|
+
# handling this in PR reviews, until such time which Rubocop provides an option
|
159
|
+
# for us to configure this.
|
160
|
+
Rails/IgnoredSkipActionFilterOption:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
# We do not care about this check due to its lack of configuration.
|
164
|
+
#
|
165
|
+
# Some of the team finds the naming of this method is more confusing than using
|
166
|
+
# `each_with_object`. We all agree the other examples are bad and should not be
|
167
|
+
# used:
|
168
|
+
#
|
169
|
+
# # OK for us
|
170
|
+
# [1, 2, 3].each_with_object({}) { |el, h| h[foo(el)] = el }
|
171
|
+
#
|
172
|
+
# # Bad
|
173
|
+
# [1, 2, 3].to_h { |el| [foo(el), el] }
|
174
|
+
# [1, 2, 3].map { |el| [foo(el), el] }.to_h
|
175
|
+
# Hash[[1, 2, 3].collect { |el| [foo(el), el] }]
|
176
|
+
#
|
177
|
+
# If this check supports configuration in the future so that we can allow
|
178
|
+
# `each_with_object` then we'll turn it back on.
|
179
|
+
Rails/IndexBy:
|
180
|
+
Enabled: false
|
181
|
+
|
182
|
+
# We find the name of this method to be very confusing. We'd prefer this method
|
183
|
+
# is never used.
|
184
|
+
Rails/IndexWith:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
# This cop enforces the use of ids over pluck(:id) and pluck(primary_key).
|
188
|
+
# https://rails.rubystyle.guide/#ids
|
189
|
+
Rails/PluckId:
|
190
|
+
Enabled: true
|
191
|
+
|
192
|
+
# This cop identifies places where pluck is used in where query methods and can be replaced with
|
193
|
+
# select. Since pluck is an eager method and hits the database immediately, using select helps to
|
194
|
+
# avoid additional database queries.
|
195
|
+
#
|
196
|
+
# When the EnforcedStyle is aggressive then all calls to pluck in the where is used as offenses.
|
197
|
+
# This may lead to false positives as the cop cannot replace to select between calls to pluck on an
|
198
|
+
# ActiveRecord::Relation instance vs a call to pluck on an Array instance.
|
199
|
+
Rails/PluckInWhere:
|
200
|
+
EnforcedStyle: aggressive
|
201
|
+
|
148
202
|
# The ActiveSupport monkey patches for `present?` are nearly all defined as:
|
149
203
|
#
|
150
204
|
# !blank?
|
@@ -205,6 +259,13 @@ Rails/ReadWriteAttribute:
|
|
205
259
|
Rails/SaveBang:
|
206
260
|
Enabled: true
|
207
261
|
|
262
|
+
# This cop enforces that short forms of I18n methods are used: t instead of translate and l instead
|
263
|
+
# of localize. We want this because it's a pain to use the full method names over and over in view
|
264
|
+
# code. When the EnforcedStyle is aggressive then all translate and localize calls without a
|
265
|
+
# receiver are added as offenses.
|
266
|
+
Rails/ShortI18n:
|
267
|
+
EnforcedStyle: aggressive
|
268
|
+
|
208
269
|
# According to the Rails docs while the following methods skip validations they
|
209
270
|
# only update the specified (single) attribute reducing risks. We'd rather not
|
210
271
|
# warn for those cases:
|
@@ -222,14 +283,19 @@ Rails/SaveBang:
|
|
222
283
|
# - http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html
|
223
284
|
# - http://api.rubyonrails.org/classes/ActiveRecord/Relation.html
|
224
285
|
#
|
225
|
-
# Configuration parameters:
|
226
|
-
#
|
286
|
+
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
287
|
+
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
|
227
288
|
Rails/SkipsModelValidations:
|
228
|
-
|
289
|
+
AllowedMethods:
|
229
290
|
- 'decrement!'
|
230
291
|
- 'increment!'
|
231
292
|
- 'touch'
|
232
293
|
|
294
|
+
# We don't want to be forced to use squish in SQL or JSON heredocs (especially
|
295
|
+
# in specs).
|
296
|
+
Rails/SquishedSQLHeredocs:
|
297
|
+
Enabled: false
|
298
|
+
|
233
299
|
# Rails uses compact style by default so we're disabling this with a :hammer:
|
234
300
|
# for things likely to be generated by Rails (i.e. most things in app).
|
235
301
|
#
|
@@ -110,6 +110,14 @@ module Radius
|
|
110
110
|
class TemplateNotFound < KeyError; end
|
111
111
|
|
112
112
|
class << self
|
113
|
+
# rubocop:disable Style/ClassMethodsDefinitions
|
114
|
+
# Style Note: We are using this class method style because we need to
|
115
|
+
# call `alias_method` within this module's singleton class context.
|
116
|
+
# Ruby did not introduce access to `singleton_class` until 2.7. Once we
|
117
|
+
# drop support for Ruby < 2.7 we can switch styles and use:
|
118
|
+
#
|
119
|
+
# singleton_class.alias_method :factory, :define_factory
|
120
|
+
|
113
121
|
# Suggested method for defining multiple factory templates at once.
|
114
122
|
#
|
115
123
|
# Most projects end up having many domain models which need factories
|
@@ -283,6 +291,7 @@ module Radius
|
|
283
291
|
def templates
|
284
292
|
@templates ||= {}
|
285
293
|
end
|
294
|
+
# rubocop:enable Style/ClassMethodsDefinitions
|
286
295
|
end
|
287
296
|
|
288
297
|
module_function
|
@@ -482,10 +491,8 @@ module Radius
|
|
482
491
|
end
|
483
492
|
|
484
493
|
# Try to load the factories defined for the specs
|
485
|
-
# rubocop:disable Lint/HandleExceptions
|
486
494
|
begin
|
487
495
|
require 'support/model_factories'
|
488
496
|
rescue LoadError
|
489
497
|
# Ignore as this is an optional convenience feature
|
490
498
|
end
|
491
|
-
# rubocop:enable Lint/HandleExceptions
|
data/lib/radius/spec/rspec.rb
CHANGED
@@ -22,6 +22,10 @@ RSpec.configure do |config|
|
|
22
22
|
# ...rather than:
|
23
23
|
# # => "be bigger than 2"
|
24
24
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
25
|
+
|
26
|
+
# The default is to warn, but this normally just gets ignored by
|
27
|
+
# developers. It's best to fix the problem then live with the warning.
|
28
|
+
expectations.on_potential_false_positives = :raise
|
25
29
|
end
|
26
30
|
|
27
31
|
# rspec-mocks config goes here. You can use an alternate test double
|
@@ -101,6 +105,11 @@ RSpec.configure do |config|
|
|
101
105
|
# as the one that triggered the failure.
|
102
106
|
Kernel.srand config.seed
|
103
107
|
|
108
|
+
# Common shared_example / shared_context inclusion alias for behavior driven
|
109
|
+
# development
|
110
|
+
config.alias_it_should_behave_like_to :has_behavior
|
111
|
+
config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
|
112
|
+
|
104
113
|
config.when_first_matching_example_defined(
|
105
114
|
:model_factory,
|
106
115
|
:model_factories,
|
data/lib/radius/spec/vcr.rb
CHANGED
@@ -91,10 +91,8 @@ RSpec.configure do |config|
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# Try to any custom VCR config for the app
|
94
|
-
# rubocop:disable Lint/HandleExceptions
|
95
94
|
begin
|
96
95
|
require 'support/vcr'
|
97
96
|
rescue LoadError
|
98
97
|
# Ignore as this is an optional convenience feature
|
99
98
|
end
|
100
|
-
# rubocop:enable Lint/HandleExceptions
|
data/lib/radius/spec/version.rb
CHANGED
data/radius-spec.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.metadata = {
|
14
14
|
"bug_tracker_uri" => "https://github.com/RadiusNetworks/radius-spec/issues",
|
15
|
-
"changelog_uri"
|
15
|
+
"changelog_uri" => "https://github.com/RadiusNetworks/radius-spec/blob/v#{Radius::Spec::VERSION}/CHANGELOG.md",
|
16
16
|
"source_code_uri" => "https://github.com/RadiusNetworks/radius-spec/tree/v#{Radius::Spec::VERSION}",
|
17
17
|
}
|
18
18
|
spec.summary = "Radius Networks RSpec setup and plug-ins"
|
@@ -21,18 +21,19 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.homepage = "https://github.com/RadiusNetworks/radius-spec"
|
22
22
|
spec.license = "Apache-2.0"
|
23
23
|
|
24
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
25
25
|
f.match(%r{^(test|spec|features)/})
|
26
|
-
|
26
|
+
}
|
27
27
|
spec.bindir = "exe"
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.required_ruby_version = ">= 2.5"
|
31
|
+
spec.required_ruby_version = ">= 2.5" # rubocop:disable Gemspec/RequiredRubyVersion
|
32
32
|
|
33
33
|
spec.add_runtime_dependency "rspec", "~> 3.7"
|
34
|
-
spec.add_runtime_dependency "rubocop", "~> 0.
|
34
|
+
spec.add_runtime_dependency "rubocop", "~> 0.90.0"
|
35
|
+
spec.add_runtime_dependency "rubocop-rails", "~> 2.9.1"
|
35
36
|
|
36
|
-
spec.add_development_dependency "bundler", "
|
37
|
-
spec.add_development_dependency "rake", "
|
37
|
+
spec.add_development_dependency "bundler", ">= 2.2.10"
|
38
|
+
spec.add_development_dependency "rake", ">= 12.0", "< 14.0"
|
38
39
|
end
|