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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbc7883d66ce748d8174fe94ba3c6649ce4a6208be40b51f41697a087b09ab58
|
|
4
|
+
data.tar.gz: ec1d727204bc3bc7f3202a0880538d45966d2be8071781e5a6ab6e5e407cfd66
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d9093dbb9207363e8c5d9637be9118c4dd06eb773943e8237ca81c6f6c6aa3687e9064a7a9d5b1cf91a15753fa4c06a81a938dd1930c4a5330df4226f837fae
|
|
7
|
+
data.tar.gz: 77f7d48b04cfb11d96fc6cce6c2d028bbb3f1f0b025016faccd573263affa13a2c39db4b78bbacd918572772ab766508af10095df0d766ee6ab3ab793c4fe2c2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'sleeping_king_studios/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
|
|
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::
|
|
33
|
+
object_tools = SleepingKingStudios::Tools::Toolbelt.instance.object_tools
|
|
27
34
|
|
|
28
|
-
if
|
|
29
|
-
comparable_value = object_tools.apply
|
|
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
|
|
33
|
-
end
|
|
34
|
-
end
|
|
39
|
+
object_tools.apply(self, expected_value, actual_value)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
35
42
|
else
|
|
36
43
|
comparable_value = expected_value
|
|
37
|
-
end
|
|
44
|
+
end
|
|
38
45
|
|
|
39
46
|
comparable_value
|
|
40
|
-
end
|
|
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
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'sleeping_king_studios/tools/toolbelt'
|
|
4
4
|
|
|
5
|
-
require 'sleeping_king_studios/
|
|
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
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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#{
|
|
40
|
-
end
|
|
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
|
|
48
|
+
end
|
|
48
49
|
|
|
49
|
-
def matches?
|
|
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
|
|
59
|
+
end
|
|
59
60
|
|
|
60
61
|
def any_keywords?
|
|
61
62
|
!!@any_keywords
|
|
62
|
-
end
|
|
63
|
+
end
|
|
63
64
|
|
|
64
65
|
def block_argument?
|
|
65
66
|
!!@block_argument
|
|
66
|
-
end
|
|
67
|
+
end
|
|
67
68
|
|
|
68
69
|
def unlimited_arguments?
|
|
69
70
|
!!@unlimited_arguments
|
|
70
|
-
end
|
|
71
|
+
end
|
|
71
72
|
|
|
72
73
|
private
|
|
73
74
|
|
|
74
75
|
attr_reader :signature
|
|
75
76
|
|
|
76
77
|
def array_tools
|
|
77
|
-
::SleepingKingStudios::Tools::
|
|
78
|
-
end
|
|
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
|
-
:
|
|
88
|
-
:
|
|
89
|
-
}
|
|
90
|
-
end
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
match = false
|
|
95
|
+
if max_arguments > signature.max_arguments
|
|
96
|
+
match = false
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
@errors[:too_many_args] = {
|
|
99
|
+
expected: signature.max_arguments,
|
|
100
|
+
received: max_arguments
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if unlimited_arguments?
|
|
105
|
+
match = false
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
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
|
|
120
|
+
end
|
|
124
121
|
|
|
125
122
|
match
|
|
126
|
-
end
|
|
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
|
|
133
|
+
end
|
|
137
134
|
|
|
138
|
-
if signature.any_keywords?
|
|
135
|
+
return match if signature.any_keywords?
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
match = false
|
|
137
|
+
unexpected_keywords = keywords - signature.keywords
|
|
138
|
+
unless unexpected_keywords.empty?
|
|
139
|
+
match = false
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
@errors[:unexpected_keywords] = unexpected_keywords
|
|
142
|
+
end
|
|
147
143
|
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
if any_keywords?
|
|
145
|
+
match = false
|
|
150
146
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
end # if-else
|
|
147
|
+
@errors[:no_variadic_keywords] = true
|
|
148
|
+
end
|
|
154
149
|
|
|
155
150
|
match
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
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.
|
|
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.
|
|
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: []
|