rspec-sleeping_king_studios 2.8.3 → 2.8.4

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: 22fdef4cb18107dee334686704c841a0237b23859d8fd3888d76acb985a8e01d
4
- data.tar.gz: 6a0968359af1d2ce3400448fd40a8647fda171534c47ec4e65c1fcb52651cd60
3
+ metadata.gz: dbc7883d66ce748d8174fe94ba3c6649ce4a6208be40b51f41697a087b09ab58
4
+ data.tar.gz: ec1d727204bc3bc7f3202a0880538d45966d2be8071781e5a6ab6e5e407cfd66
5
5
  SHA512:
6
- metadata.gz: 71aeb0c2c91bedeaad195827e7346724a04516e42872305d75d89d996789697b770d6256c1008ce556fc7d497d7337ed991c34be837594a64738fb63b62f2b3a
7
- data.tar.gz: 529427a25ff965bbb1950bb93776864245669beca3bd777fcca33a942bcb834d424cca7f54e61081e64718a77c9f1a9e22d20279216a06fa919a8b32a99125e0
6
+ metadata.gz: 3d9093dbb9207363e8c5d9637be9118c4dd06eb773943e8237ca81c6f6c6aa3687e9064a7a9d5b1cf91a15753fa4c06a81a938dd1930c4a5330df4226f837fae
7
+ data.tar.gz: 77f7d48b04cfb11d96fc6cce6c2d028bbb3f1f0b025016faccd573263affa13a2c39db4b78bbacd918572772ab766508af10095df0d766ee6ab3ab793c4fe2c2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.8.4
4
+
5
+ Fixed deprecated direct reference to `SleepingKingStudios::Tools` methods.
6
+
3
7
  ## 2.8.3
4
8
 
5
9
  Added support for Ruby 4.0.
@@ -1,12 +1,12 @@
1
- # lib/rspec/sleeping_king_studios/examples/property_examples.rb
1
+ # frozen_string_literal: true
2
2
 
3
- require 'sleeping_king_studios/tools/object_tools'
3
+ require 'sleeping_king_studios/tools/toolbelt'
4
4
 
5
5
  require 'rspec/sleeping_king_studios/concerns/shared_example_group'
6
6
  require 'rspec/sleeping_king_studios/examples'
7
- require 'rspec/sleeping_king_studios/examples/property_examples/class_properties'
7
+ require 'rspec/sleeping_king_studios/examples/property_examples/class_properties' # rubocop:disable Layout/LineLength
8
8
  require 'rspec/sleeping_king_studios/examples/property_examples/constants'
9
- require 'rspec/sleeping_king_studios/examples/property_examples/private_properties'
9
+ require 'rspec/sleeping_king_studios/examples/property_examples/private_properties' # rubocop:disable Layout/LineLength
10
10
  require 'rspec/sleeping_king_studios/examples/property_examples/predicates'
11
11
  require 'rspec/sleeping_king_studios/examples/property_examples/properties'
12
12
 
@@ -14,6 +14,11 @@ require 'rspec/sleeping_king_studios/examples/property_examples/properties'
14
14
  # writer methods.
15
15
  module RSpec::SleepingKingStudios::Examples::PropertyExamples
16
16
  extend RSpec::SleepingKingStudios::Concerns::SharedExampleGroup
17
+ include RSpec::SleepingKingStudios::Examples::PropertyExamples::ClassProperties
18
+ include RSpec::SleepingKingStudios::Examples::PropertyExamples::Constants
19
+ include RSpec::SleepingKingStudios::Examples::PropertyExamples::PrivateProperties
20
+ include RSpec::SleepingKingStudios::Examples::PropertyExamples::Predicates
21
+ include RSpec::SleepingKingStudios::Examples::PropertyExamples::Properties
17
22
 
18
23
  # @api private
19
24
  #
@@ -21,27 +26,23 @@ module RSpec::SleepingKingStudios::Examples::PropertyExamples
21
26
  # value expectation.
22
27
  UNDEFINED_VALUE_EXPECTATION = Object.new.freeze
23
28
 
24
- private def format_expected_value expected_value
29
+ private
30
+
31
+ def format_expected_value(expected_value) # rubocop:disable Metrics/MethodLength
25
32
  if expected_value.is_a?(Proc)
26
- object_tools = SleepingKingStudios::Tools::ObjectTools
33
+ object_tools = SleepingKingStudios::Tools::Toolbelt.instance.object_tools
27
34
 
28
- if 0 == expected_value.arity
29
- comparable_value = object_tools.apply self, expected_value
35
+ if expected_value.arity.zero?
36
+ comparable_value = object_tools.apply(self, expected_value)
30
37
  else
31
38
  comparable_value = satisfy do |actual_value|
32
- object_tools.apply self, expected_value, actual_value
33
- end # satisfy
34
- end # if-else
39
+ object_tools.apply(self, expected_value, actual_value)
40
+ end
41
+ end
35
42
  else
36
43
  comparable_value = expected_value
37
- end # if
44
+ end
38
45
 
39
46
  comparable_value
40
- end # method format_expected_value
41
-
42
- include RSpec::SleepingKingStudios::Examples::PropertyExamples::ClassProperties
43
- include RSpec::SleepingKingStudios::Examples::PropertyExamples::Constants
44
- include RSpec::SleepingKingStudios::Examples::PropertyExamples::PrivateProperties
45
- include RSpec::SleepingKingStudios::Examples::PropertyExamples::Predicates
46
- include RSpec::SleepingKingStudios::Examples::PropertyExamples::Properties
47
- end # module
47
+ end
48
+ end
@@ -1,12 +1,12 @@
1
- # lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rspec/sleeping_king_studios/support/method_signature'
3
+ require 'sleeping_king_studios/tools/toolbelt'
4
4
 
5
- require 'sleeping_king_studios/tools/array_tools'
5
+ require 'rspec/sleeping_king_studios/support/method_signature'
6
6
 
7
7
  module RSpec::SleepingKingStudios::Support
8
8
  # @api private
9
- class MethodSignatureExpectation
9
+ class MethodSignatureExpectation # rubocop:disable Metrics/ClassLength
10
10
  def initialize
11
11
  @min_arguments = 0
12
12
  @max_arguments = 0
@@ -15,7 +15,7 @@ module RSpec::SleepingKingStudios::Support
15
15
  @any_keywords = false
16
16
  @block_argument = false
17
17
  @errors = {}
18
- end # method initialize
18
+ end
19
19
 
20
20
  attr_accessor :min_arguments, :max_arguments, :keywords
21
21
 
@@ -23,30 +23,31 @@ module RSpec::SleepingKingStudios::Support
23
23
 
24
24
  attr_reader :errors
25
25
 
26
- def description
26
+ def description # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
27
27
  messages = []
28
28
 
29
- if min_arguments == max_arguments
30
- messages << "#{min_arguments} argument#{1 == min_arguments ? '' : 's'}"
31
- else
32
- messages << "#{min_arguments}..#{max_arguments} arguments"
33
- end # if-else
29
+ messages <<
30
+ if min_arguments == max_arguments
31
+ "#{min_arguments} argument#{'s' unless min_arguments == 1}"
32
+ else
33
+ "#{min_arguments}..#{max_arguments} arguments"
34
+ end
34
35
 
35
36
  messages << 'unlimited arguments' if unlimited_arguments?
36
37
 
37
38
  unless keywords.empty?
38
39
  keywords_list = array_tools.humanize_list keywords.map(&:inspect)
39
- messages << "keyword#{1 == keywords.count ? '' : 's'} #{keywords_list}"
40
- end # if
40
+ messages << "keyword#{'s' unless keywords.one?} #{keywords_list}"
41
+ end
41
42
 
42
43
  messages << 'arbitrary keywords' if any_keywords?
43
44
 
44
45
  messages << 'a block' if block_argument?
45
46
 
46
47
  "with #{array_tools.humanize_list messages}"
47
- end # method description
48
+ end
48
49
 
49
- def matches? method
50
+ def matches?(method)
50
51
  @signature = MethodSignature.new(method)
51
52
  @errors = {}
52
53
 
@@ -55,63 +56,59 @@ module RSpec::SleepingKingStudios::Support
55
56
  match = false unless matches_keywords?
56
57
  match = false unless matches_block?
57
58
  match
58
- end # method matches?
59
+ end
59
60
 
60
61
  def any_keywords?
61
62
  !!@any_keywords
62
- end # method any_keywords?
63
+ end
63
64
 
64
65
  def block_argument?
65
66
  !!@block_argument
66
- end # method block_argument?
67
+ end
67
68
 
68
69
  def unlimited_arguments?
69
70
  !!@unlimited_arguments
70
- end # method unlimited_arguments?
71
+ end
71
72
 
72
73
  private
73
74
 
74
75
  attr_reader :signature
75
76
 
76
77
  def array_tools
77
- ::SleepingKingStudios::Tools::ArrayTools
78
- end # method array_tools
78
+ ::SleepingKingStudios::Tools::Toolbelt.instance.array_tools
79
+ end
79
80
 
80
- def matches_arity?
81
+ def matches_arity? # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
81
82
  match = true
82
83
 
83
84
  if min_arguments < signature.min_arguments
84
85
  match = false
85
86
 
86
87
  @errors[:not_enough_args] = {
87
- :expected => signature.min_arguments,
88
- :received => min_arguments
89
- } # end hash
90
- end # if
88
+ expected: signature.min_arguments,
89
+ received: min_arguments
90
+ }
91
+ end
91
92
 
92
- if signature.unlimited_arguments?
93
+ return match if signature.unlimited_arguments?
93
94
 
94
- else
95
- if max_arguments > signature.max_arguments
96
- match = false
95
+ if max_arguments > signature.max_arguments
96
+ match = false
97
97
 
98
- @errors[:too_many_args] = {
99
- :expected => signature.max_arguments,
100
- :received => max_arguments
101
- } # end hash
102
- end # if-else
98
+ @errors[:too_many_args] = {
99
+ expected: signature.max_arguments,
100
+ received: max_arguments
101
+ }
102
+ end
103
103
 
104
- if unlimited_arguments?
105
- match = false
104
+ if unlimited_arguments?
105
+ match = false
106
106
 
107
- @errors[:no_variadic_args] = {
108
- :expected => signature.max_arguments
109
- } # end hash
110
- end # if
111
- end # if-else
107
+ @errors[:no_variadic_args] = { expected: signature.max_arguments }
108
+ end
112
109
 
113
110
  match
114
- end # method matches_arity?
111
+ end
115
112
 
116
113
  def matches_block?
117
114
  match = true
@@ -120,12 +117,12 @@ module RSpec::SleepingKingStudios::Support
120
117
  match = false
121
118
 
122
119
  @errors[:no_block_argument] = true
123
- end # if
120
+ end
124
121
 
125
122
  match
126
- end # method matches_block?
123
+ end
127
124
 
128
- def matches_keywords?
125
+ def matches_keywords? # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
129
126
  match = true
130
127
 
131
128
  missing_keywords = signature.required_keywords - keywords
@@ -133,26 +130,24 @@ module RSpec::SleepingKingStudios::Support
133
130
  match = false
134
131
 
135
132
  @errors[:missing_keywords] = missing_keywords
136
- end # unless
133
+ end
137
134
 
138
- if signature.any_keywords?
135
+ return match if signature.any_keywords?
139
136
 
140
- else
141
- unexpected_keywords = keywords - signature.keywords
142
- unless unexpected_keywords.empty?
143
- match = false
137
+ unexpected_keywords = keywords - signature.keywords
138
+ unless unexpected_keywords.empty?
139
+ match = false
144
140
 
145
- @errors[:unexpected_keywords] = unexpected_keywords
146
- end # unless
141
+ @errors[:unexpected_keywords] = unexpected_keywords
142
+ end
147
143
 
148
- if any_keywords?
149
- match = false
144
+ if any_keywords?
145
+ match = false
150
146
 
151
- @errors[:no_variadic_keywords] = true
152
- end # if
153
- end # if-else
147
+ @errors[:no_variadic_keywords] = true
148
+ end
154
149
 
155
150
  match
156
- end # method matches_keywords?
157
- end # class
158
- end # module
151
+ end
152
+ end
153
+ end
@@ -13,7 +13,7 @@ module RSpec
13
13
  # Minor version.
14
14
  MINOR = 8
15
15
  # Patch version.
16
- PATCH = 3
16
+ PATCH = 4
17
17
  # Prerelease version.
18
18
  PRERELEASE = nil
19
19
  # Build metadata.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sleeping_king_studios
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.3
4
+ version: 2.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob "Merlin" Smith
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 4.0.2
193
+ rubygems_version: 4.0.3
194
194
  specification_version: 4
195
195
  summary: A collection of RSpec patches and custom matchers.
196
196
  test_files: []