radius-spec 0.8.0 → 0.9.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: c90e6b5072e71e6bb5c5ef37ccbbc9f0b874c151d156bdb3e9af92aeba0caeb1
4
- data.tar.gz: 2781ec9668af9583f4ac7c73de5de2f52e634e3d063e94feb305095de4b36f75
3
+ metadata.gz: b6b5e94783c4ccbdf8bdf80de184fc19cd52ac9ee9f2a7f92329b261bdb00f59
4
+ data.tar.gz: e492ea78f99e146011d2279e74fc1a3b1091aac13f311ef81324df43088ce440
5
5
  SHA512:
6
- metadata.gz: 9b685ea0852391ce5a52c1810bd10d923ff007d9968a4dce483ca147d2057c0e320c15c413abcef900c810cb241dc98b2e633d7b65176a87fbc863d5f2dad26b
7
- data.tar.gz: 97ea01566899ea8641f86771f54147875e649eb18669871b2f6db640d6bce912982e5e53690b051b70aece3cd231275fe38c074c3e28cdc5670860c04d6579e4
6
+ metadata.gz: 83005750c2029b0a2765e176a8d819ed7984376c13ac17b881b442d055956ffd28548c32af56bb7298b1cc60d976c0c3cb25d10bbc2aed5bec0f4b16c72e8324
7
+ data.tar.gz: 95d8183b73cfa36c5f3e01680bf6d2212016e2355d0a14ed95b7d38800b4d2e44ce9d08dbcdd0336bf6beb20731bfb3a834258a13b6ad357443918c4ec505ae8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## 0.9.0 (September 30, 2021)
2
+
3
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.8.0...v0.9.0)
4
+
5
+ ### Enhancements
6
+
7
+ - Upgrade to Rubocop 0.89.x (Aaron Hill, Aaron Kromer, Ben Reynolds, Chris
8
+ Hoffman, James Nebeker, JC Avena, Sam Kim #27)
9
+ - Upgrade to Rubocop Rails 2.6.x (Aaron Hill, Aaron Kromer, Ben Reynolds, Chris
10
+ Hoffman, James Nebeker, JC Avena, Sam Kim #27)
11
+ - Adjust common Rubocop configuration (Aaron Hill, Aaron Kromer, Ben Reynolds,
12
+ Chris Hoffman, James Nebeker, JC Avena, Sam Kim #27)
13
+ - Configure multiple metrics to use the `CountAsOne` option for array, hash
14
+ and heredocs
15
+ - Disable `Style/SlicingWithRange` as we do not care about the style
16
+ - Includes new `shared_example` / `shared_context` inclusion aliases
17
+ `has_behavior` and `it_has_behavior` for behavior driven development language
18
+ (Aaron Kromer, Ben Reynolds #28)
19
+
20
+ ### Bug Fixes
21
+
22
+ None
23
+
24
+ ### Breaking Change
25
+
26
+ - Change the default behavior from `:warn` to `:raise` for RSpec expectations
27
+ behavior `on_potential_false_positives` (Aaron Kromer, Ben Reynolds #28)
28
+
29
+
1
30
  ## 0.8.0 (August 26, 2021)
2
31
 
3
32
  [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.7.0...v0.8.0)
@@ -0,0 +1,285 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Data values are taken from the Rubocop Style/HashLikeCase example
4
+ #
5
+ # https://docs.rubocop.org/rubocop/1.21/cops_style.html#styleredundantfileextensioninrequire
6
+
7
+ # Run from the command line: bundle exec ruby benchmarks/style_hash_like_case.rb
8
+ require_relative 'bm_setup'
9
+
10
+ display_benchmark_header
11
+
12
+ # rubocop:disable Style/HashLikeCase
13
+ def case_check3(value)
14
+ case value
15
+ when 'europe'
16
+ 'http://eu.example.com'
17
+ when 'america'
18
+ 'http://us.example.com'
19
+ when 'australia'
20
+ 'http://au.example.com'
21
+ end
22
+ end
23
+
24
+ HASH_CASE3 = {
25
+ 'europe' => 'http://eu.example.com',
26
+ 'america' => 'http://us.example.com',
27
+ 'australia' => 'http://au.example.com',
28
+ }.freeze
29
+
30
+ def hash_check3(value)
31
+ HASH_CASE3[value]
32
+ end
33
+
34
+ section "Style/HashLikeCase(3) - First Match" do |bench|
35
+ bench.report("case") do |times|
36
+ i = 0
37
+ while i < times
38
+ case_check3('europe')
39
+ i += 1
40
+ end
41
+ end
42
+
43
+ bench.report("hash") do |times|
44
+ i = 0
45
+ while i < times
46
+ hash_check3('europe')
47
+ i += 1
48
+ end
49
+ end
50
+ end
51
+
52
+ section "Style/HashLikeCase(3) - Last Match" do |bench|
53
+ bench.report("case") do |times|
54
+ i = 0
55
+ while i < times
56
+ case_check3('australia')
57
+ i += 1
58
+ end
59
+ end
60
+
61
+ bench.report("hash") do |times|
62
+ i = 0
63
+ while i < times
64
+ hash_check3('australia')
65
+ i += 1
66
+ end
67
+ end
68
+ end
69
+
70
+ section "Style/HashLikeCase(3) - No Match" do |bench|
71
+ bench.report("case") do |times|
72
+ i = 0
73
+ while i < times
74
+ case_check3('any other place')
75
+ i += 1
76
+ end
77
+ end
78
+
79
+ bench.report("hash") do |times|
80
+ i = 0
81
+ while i < times
82
+ hash_check3('any other place')
83
+ i += 1
84
+ end
85
+ end
86
+ end
87
+
88
+ def case_check5(value) # rubocop:disable Metrics/MethodLength
89
+ case value
90
+ when 'europe'
91
+ 'http://eu.example.com'
92
+ when 'america'
93
+ 'http://us.example.com'
94
+ when 'australia'
95
+ 'http://au.example.com'
96
+ when 'china'
97
+ 'http://cn.example.com'
98
+ when 'japan'
99
+ 'http://jp.example.com'
100
+ end
101
+ end
102
+
103
+ HASH_CASE5 = {
104
+ 'europe' => 'http://eu.example.com',
105
+ 'america' => 'http://us.example.com',
106
+ 'australia' => 'http://au.example.com',
107
+ 'china' => 'http://cn.example.com',
108
+ 'japan' => 'http://jp.example.com',
109
+ }.freeze
110
+
111
+ def hash_check5(value)
112
+ HASH_CASE5[value]
113
+ end
114
+
115
+ section "Style/HashLikeCase(5) - First Match" do |bench|
116
+ bench.report("case") do |times|
117
+ i = 0
118
+ while i < times
119
+ case_check5('europe')
120
+ i += 1
121
+ end
122
+ end
123
+
124
+ bench.report("hash") do |times|
125
+ i = 0
126
+ while i < times
127
+ hash_check5('europe')
128
+ i += 1
129
+ end
130
+ end
131
+ end
132
+
133
+ section "Style/HashLikeCase(5) - Last Match" do |bench|
134
+ bench.report("case") do |times|
135
+ i = 0
136
+ while i < times
137
+ case_check5('japan')
138
+ i += 1
139
+ end
140
+ end
141
+
142
+ bench.report("hash") do |times|
143
+ i = 0
144
+ while i < times
145
+ hash_check5('japan')
146
+ i += 1
147
+ end
148
+ end
149
+ end
150
+
151
+ section "Style/HashLikeCase(5) - No Match" do |bench|
152
+ bench.report("case") do |times|
153
+ i = 0
154
+ while i < times
155
+ case_check5('any other place')
156
+ i += 1
157
+ end
158
+ end
159
+
160
+ bench.report("hash") do |times|
161
+ i = 0
162
+ while i < times
163
+ hash_check5('any other place')
164
+ i += 1
165
+ end
166
+ end
167
+ end
168
+
169
+ # rubocop:enable Style/HashLikeCase
170
+
171
+ __END__
172
+
173
+ Usage of `case` appears to be more performant than a hash. However, both are
174
+ highly performant, so any difference is likely negligible compared to other
175
+ performance issues.
176
+
177
+ ### Environment
178
+
179
+ Performance-M Dyno
180
+ ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
181
+ GC Disabled: true
182
+
183
+ ### Test Cases
184
+
185
+ #### Style/HashLikeCase(3) - First Match
186
+
187
+ ```
188
+ Warming up --------------------------------------
189
+ case 1.768M i/100ms
190
+ hash 1.710M i/100ms
191
+ Calculating -------------------------------------
192
+ case 17.630M (± 0.3%) i/s - 88.418M in 5.016811s
193
+ hash 17.044M (± 0.2%) i/s - 85.504M in 5.017564s
194
+ with 95.0% confidence
195
+
196
+ Comparison:
197
+ case: 17630438.8 i/s
198
+ hash: 17044158.0 i/s - 1.03x (± 0.00) slower
199
+ with 95.0% confidence
200
+ ```
201
+
202
+ #### Style/HashLikeCase(3) - Last Match
203
+
204
+ ```
205
+ Warming up --------------------------------------
206
+ case 1.714M i/100ms
207
+ hash 1.644M i/100ms
208
+ Calculating -------------------------------------
209
+ case 17.066M (± 0.7%) i/s - 85.718M in 5.027638s
210
+ hash 16.432M (± 0.1%) i/s - 82.205M in 5.002925s
211
+ with 95.0% confidence
212
+
213
+ Comparison:
214
+ case: 17066448.1 i/s
215
+ hash: 16432193.1 i/s - 1.04x (± 0.01) slower
216
+ with 95.0% confidence
217
+ ```
218
+
219
+ #### Style/HashLikeCase(3) - No Match
220
+
221
+ ```
222
+ Warming up --------------------------------------
223
+ case 1.706M i/100ms
224
+ hash 1.529M i/100ms
225
+ Calculating -------------------------------------
226
+ case 16.944M (± 0.8%) i/s - 85.300M in 5.041700s
227
+ hash 15.210M (± 0.5%) i/s - 76.428M in 5.028693s
228
+ with 95.0% confidence
229
+
230
+ Comparison:
231
+ case: 16944279.7 i/s
232
+ hash: 15210481.2 i/s - 1.11x (± 0.01) slower
233
+ with 95.0% confidence
234
+ ```
235
+
236
+ #### Style/HashLikeCase(5) - First Match
237
+
238
+ ```
239
+ Warming up --------------------------------------
240
+ case 1.738M i/100ms
241
+ hash 1.704M i/100ms
242
+ Calculating -------------------------------------
243
+ case 17.621M (± 0.5%) i/s - 88.642M in 5.033716s
244
+ hash 16.963M (± 0.5%) i/s - 85.198M in 5.025691s
245
+ with 95.0% confidence
246
+
247
+ Comparison:
248
+ case: 17621070.3 i/s
249
+ hash: 16963331.9 i/s - 1.04x (± 0.01) slower
250
+ with 95.0% confidence
251
+ ```
252
+
253
+ #### Style/HashLikeCase(5) - Last Match
254
+
255
+ ```
256
+ Warming up --------------------------------------
257
+ case 1.718M i/100ms
258
+ hash 1.634M i/100ms
259
+ Calculating -------------------------------------
260
+ case 17.170M (± 0.0%) i/s - 85.898M in 5.002845s
261
+ hash 16.357M (± 0.3%) i/s - 83.338M in 5.097011s
262
+ with 95.0% confidence
263
+
264
+ Comparison:
265
+ case: 17170019.6 i/s
266
+ hash: 16356675.5 i/s - 1.05x (± 0.00) slower
267
+ with 95.0% confidence
268
+ ```
269
+
270
+ #### Style/HashLikeCase(5) - No Match
271
+
272
+ ```
273
+ Warming up --------------------------------------
274
+ case 1.661M i/100ms
275
+ hash 1.501M i/100ms
276
+ Calculating -------------------------------------
277
+ case 16.518M (± 0.6%) i/s - 83.046M in 5.031835s
278
+ hash 14.963M (± 0.5%) i/s - 75.058M in 5.019838s
279
+ with 95.0% confidence
280
+
281
+ Comparison:
282
+ case: 16517985.2 i/s
283
+ hash: 14962803.1 i/s - 1.10x (± 0.01) slower
284
+ with 95.0% confidence
285
+ ```
data/common_rubocop.yml CHANGED
@@ -91,15 +91,6 @@ Layout/BlockAlignment:
91
91
  Layout/FirstArgumentIndentation:
92
92
  Enabled: false
93
93
 
94
- # This project only uses newer Ruby versions which all support the "squiggly"
95
- # style. We prefer to use pure Ruby calls when possible instead of relying on
96
- # alternatives; even for Rails app.
97
- #
98
- # Configuration parameters: EnforcedStyle.
99
- # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
100
- Layout/HeredocIndentation:
101
- EnforcedStyle: squiggly
102
-
103
94
  # We generally prefer to use the default line length of 80. Though sometimes
104
95
  # we just need a little extra space because it makes it easier to read.
105
96
  #
@@ -214,6 +205,10 @@ Metrics/AbcSize:
214
205
  # Configuration parameters: CountComments, ExcludedMethods, Max.
215
206
  # ExcludedMethods: refine
216
207
  Metrics/BlockLength:
208
+ CountAsOne:
209
+ - 'array'
210
+ - 'hash'
211
+ - 'heredoc'
217
212
  Exclude:
218
213
  - '**/Rakefile'
219
214
  - '**/*.rake'
@@ -227,11 +222,25 @@ Metrics/BlockLength:
227
222
  - 'RSpec.configure'
228
223
  - 'VCR.configure'
229
224
 
230
- # TODO: Remove this when we get to 0.89.0 as the new default max is 8
231
- #
232
- # Configuration parameters: IgnoredMethods, Max
233
- Metrics/PerceivedComplexity:
234
- Max: 8
225
+ # We want length related code metrics to count Hashs, Arrays, and
226
+ # Heredocs as one "line"
227
+ Metrics/ClassLength:
228
+ CountAsOne:
229
+ - 'array'
230
+ - 'hash'
231
+ - 'heredoc'
232
+
233
+ Metrics/ModuleLength:
234
+ CountAsOne:
235
+ - 'array'
236
+ - 'hash'
237
+ - 'heredoc'
238
+
239
+ Metrics/MethodLength:
240
+ CountAsOne:
241
+ - 'array'
242
+ - 'hash'
243
+ - 'heredoc'
235
244
 
236
245
  # This is overly pedantic (only allowing `other` as the parameter name). Ruby
237
246
  # core doesn't follow this consistently either. Looking at several classes
@@ -640,6 +649,11 @@ Style/RescueStandardError:
640
649
  Avoid rescuing `Exception` as this may hide system errors.
641
650
  EnforcedStyle: implicit
642
651
 
652
+ # We don't really care which style we use here and would prefer rubocop not
653
+ # complain about this.
654
+ Style/SlicingWithRange:
655
+ Enabled: false
656
+
643
657
  # We generally prefer double quotes but many generators use single quotes. We
644
658
  # don't view the performance difference to be all that much so we don't care
645
659
  # if the style is mixed or double quotes are used for static strings.
@@ -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,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radius
4
4
  module Spec
5
- VERSION = "0.8.0"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
data/radius-spec.gemspec CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
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.82.0"
35
- spec.add_runtime_dependency "rubocop-rails", "~> 2.5.2"
34
+ spec.add_runtime_dependency "rubocop", "~> 0.89.0"
35
+ spec.add_runtime_dependency "rubocop-rails", "~> 2.6.0"
36
36
 
37
37
  spec.add_development_dependency "bundler", ">= 2.2.10"
38
38
  spec.add_development_dependency "rake", ">= 12.0", "< 14.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radius-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radius Networks
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-08-26 00:00:00.000000000 Z
12
+ date: 2021-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -31,28 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.82.0
34
+ version: 0.89.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.82.0
41
+ version: 0.89.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rubocop-rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.5.2
48
+ version: 2.6.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 2.5.2
55
+ version: 2.6.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,7 @@ files:
123
123
  - benchmarks/kwargs.rb
124
124
  - benchmarks/max_ternary.rb
125
125
  - benchmarks/max_ternary_micro.rb
126
+ - benchmarks/style_hash_like_case.rb
126
127
  - benchmarks/unfreeze_string.rb
127
128
  - benchmarks/unpack_first.rb
128
129
  - bin/ci
@@ -149,8 +150,8 @@ licenses:
149
150
  - Apache-2.0
150
151
  metadata:
151
152
  bug_tracker_uri: https://github.com/RadiusNetworks/radius-spec/issues
152
- changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.8.0/CHANGELOG.md
153
- source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.8.0
153
+ changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.9.0/CHANGELOG.md
154
+ source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.9.0
154
155
  post_install_message:
155
156
  rdoc_options: []
156
157
  require_paths:
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  - !ruby/object:Gem::Version
167
168
  version: '0'
168
169
  requirements: []
169
- rubygems_version: 3.1.6
170
+ rubygems_version: 3.1.2
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Radius Networks RSpec setup and plug-ins