rspec-sleeping_king_studios 2.6.0 → 2.7.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/DEVELOPMENT.md +0 -4
- data/README.md +235 -162
- data/lib/rspec/sleeping_king_studios/all.rb +1 -0
- data/lib/rspec/sleeping_king_studios/concerns/include_contract.rb +260 -0
- data/lib/rspec/sleeping_king_studios/contract.rb +165 -0
- data/lib/rspec/sleeping_king_studios/matchers/core/alias_method.rb +8 -2
- data/lib/rspec/sleeping_king_studios/matchers/core/alias_method_matcher.rb +12 -97
- data/lib/rspec/sleeping_king_studios/matchers/core/delegate_method_matcher.rb +8 -1
- data/lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method.rb +12 -0
- data/lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method_matcher.rb +114 -0
- data/lib/rspec/sleeping_king_studios/version.rb +31 -17
- metadata +9 -4
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rspec/sleeping_king_studios/matchers/base_matcher'
|
4
|
+
require 'rspec/sleeping_king_studios/matchers/core'
|
5
|
+
|
6
|
+
module RSpec::SleepingKingStudios::Matchers::Core
|
7
|
+
# Matcher for testing whether an object aliases a specified method using the
|
8
|
+
# specified other method name.
|
9
|
+
#
|
10
|
+
# @since 2.2.0
|
11
|
+
#
|
12
|
+
# @note Prior to 2.7.0, this was named AliasMethodMatcher.
|
13
|
+
class HaveAliasedMethodMatcher < RSpec::SleepingKingStudios::Matchers::BaseMatcher
|
14
|
+
# @param [String, Symbol] original_name The name of the method that is
|
15
|
+
# expected to have an alias.
|
16
|
+
def initialize(original_name)
|
17
|
+
@original_name = original_name.intern
|
18
|
+
end
|
19
|
+
|
20
|
+
# Specifies the name of the new method.
|
21
|
+
#
|
22
|
+
# @param [String, Symbol] aliased_name The method name.
|
23
|
+
#
|
24
|
+
# @return [AliasMethodMatcher] self
|
25
|
+
def as(aliased_name)
|
26
|
+
@aliased_name = aliased_name
|
27
|
+
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
# (see BaseMatcher#description)
|
32
|
+
def description
|
33
|
+
str = "alias :#{original_name}"
|
34
|
+
|
35
|
+
str += " as #{aliased_name.inspect}" if aliased_name
|
36
|
+
|
37
|
+
str
|
38
|
+
end
|
39
|
+
|
40
|
+
# (see BaseMatcher#failure_message)
|
41
|
+
def failure_message
|
42
|
+
message = "expected #{@actual.inspect} to alias :#{original_name}"
|
43
|
+
|
44
|
+
message += " as #{aliased_name.inspect}" if aliased_name
|
45
|
+
|
46
|
+
if @errors[:does_not_respond_to_old_method]
|
47
|
+
message += ", but did not respond to :#{original_name}"
|
48
|
+
|
49
|
+
return message
|
50
|
+
end
|
51
|
+
|
52
|
+
if @errors[:does_not_respond_to_new_method]
|
53
|
+
message += ", but did not respond to :#{aliased_name}"
|
54
|
+
|
55
|
+
return message
|
56
|
+
end
|
57
|
+
|
58
|
+
if @errors[:does_not_alias_method]
|
59
|
+
message +=
|
60
|
+
", but :#{original_name} and :#{aliased_name} are different "\
|
61
|
+
"methods"
|
62
|
+
|
63
|
+
return message
|
64
|
+
end
|
65
|
+
|
66
|
+
message
|
67
|
+
end
|
68
|
+
|
69
|
+
# (see BaseMatcher#matches?)
|
70
|
+
def matches?(actual)
|
71
|
+
super
|
72
|
+
|
73
|
+
@errors = {}
|
74
|
+
|
75
|
+
if aliased_name.nil?
|
76
|
+
raise ArgumentError.new('must specify a new method name')
|
77
|
+
end
|
78
|
+
|
79
|
+
responds_to_methods? && aliases_method?
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
attr_reader :aliased_name
|
85
|
+
|
86
|
+
attr_reader :original_name
|
87
|
+
|
88
|
+
def aliases_method?
|
89
|
+
unless @actual.method(original_name) == @actual.method(aliased_name)
|
90
|
+
@errors[:does_not_alias_method] = true
|
91
|
+
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
def responds_to_methods?
|
99
|
+
unless @actual.respond_to?(original_name)
|
100
|
+
@errors[:does_not_respond_to_old_method] = true
|
101
|
+
|
102
|
+
return false
|
103
|
+
end
|
104
|
+
|
105
|
+
unless @actual.respond_to?(aliased_name)
|
106
|
+
@errors[:does_not_respond_to_new_method] = true
|
107
|
+
|
108
|
+
return false
|
109
|
+
end
|
110
|
+
|
111
|
+
true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -11,31 +11,45 @@ module RSpec
|
|
11
11
|
# Major version.
|
12
12
|
MAJOR = 2
|
13
13
|
# Minor version.
|
14
|
-
MINOR =
|
14
|
+
MINOR = 7
|
15
15
|
# Patch version.
|
16
16
|
PATCH = 0
|
17
17
|
# Prerelease version.
|
18
|
-
PRERELEASE =
|
18
|
+
PRERELEASE = :rc
|
19
19
|
# Build metadata.
|
20
|
-
BUILD =
|
20
|
+
BUILD = 0
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
class << self
|
23
|
+
# Generates the gem version string from the Version constants.
|
24
|
+
#
|
25
|
+
# Inlined here because dependencies may not be loaded when processing a
|
26
|
+
# gemspec, which results in the user being unable to install the gem for
|
27
|
+
# the first time.
|
28
|
+
#
|
29
|
+
# @see SleepingKingStudios::Tools::SemanticVersion#to_gem_version
|
30
|
+
def to_gem_version
|
31
|
+
str = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
prerelease = value_of(:PRERELEASE)
|
34
|
+
str = "#{str}.#{prerelease}" if prerelease
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
build = value_of(:BUILD)
|
37
|
+
str = "#{str}.#{build}" if build
|
37
38
|
|
38
|
-
|
39
|
+
str
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def value_of(constant)
|
45
|
+
return nil unless const_defined?(constant)
|
46
|
+
|
47
|
+
value = const_get(constant)
|
48
|
+
|
49
|
+
return nil if value.respond_to?(:empty?) && value.empty?
|
50
|
+
|
51
|
+
value
|
52
|
+
end
|
39
53
|
end
|
40
54
|
end
|
41
55
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sleeping_king_studios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob "Merlin" Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashdiff
|
@@ -199,6 +199,7 @@ extensions: []
|
|
199
199
|
extra_rdoc_files: []
|
200
200
|
files:
|
201
201
|
- CHANGELOG.md
|
202
|
+
- CODE_OF_CONDUCT.md
|
202
203
|
- DEVELOPMENT.md
|
203
204
|
- LICENSE
|
204
205
|
- README.md
|
@@ -208,11 +209,13 @@ files:
|
|
208
209
|
- lib/rspec/sleeping_king_studios/concerns/all.rb
|
209
210
|
- lib/rspec/sleeping_king_studios/concerns/example_constants.rb
|
210
211
|
- lib/rspec/sleeping_king_studios/concerns/focus_examples.rb
|
212
|
+
- lib/rspec/sleeping_king_studios/concerns/include_contract.rb
|
211
213
|
- lib/rspec/sleeping_king_studios/concerns/shared_example_group.rb
|
212
214
|
- lib/rspec/sleeping_king_studios/concerns/toolbelt.rb
|
213
215
|
- lib/rspec/sleeping_king_studios/concerns/wrap_env.rb
|
214
216
|
- lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb
|
215
217
|
- lib/rspec/sleeping_king_studios/configuration.rb
|
218
|
+
- lib/rspec/sleeping_king_studios/contract.rb
|
216
219
|
- lib/rspec/sleeping_king_studios/examples.rb
|
217
220
|
- lib/rspec/sleeping_king_studios/examples/all.rb
|
218
221
|
- lib/rspec/sleeping_king_studios/examples/property_examples.rb
|
@@ -253,6 +256,8 @@ files:
|
|
253
256
|
- lib/rspec/sleeping_king_studios/matchers/core/deep_matcher.rb
|
254
257
|
- lib/rspec/sleeping_king_studios/matchers/core/delegate_method.rb
|
255
258
|
- lib/rspec/sleeping_king_studios/matchers/core/delegate_method_matcher.rb
|
259
|
+
- lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method.rb
|
260
|
+
- lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method_matcher.rb
|
256
261
|
- lib/rspec/sleeping_king_studios/matchers/core/have_changed.rb
|
257
262
|
- lib/rspec/sleeping_king_studios/matchers/core/have_changed_matcher.rb
|
258
263
|
- lib/rspec/sleeping_king_studios/matchers/core/have_constant.rb
|
@@ -291,9 +296,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
291
296
|
version: '0'
|
292
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
298
|
requirements:
|
294
|
-
- - "
|
299
|
+
- - ">"
|
295
300
|
- !ruby/object:Gem::Version
|
296
|
-
version:
|
301
|
+
version: 1.3.1
|
297
302
|
requirements: []
|
298
303
|
rubygems_version: 3.1.2
|
299
304
|
signing_key:
|