sinclair 1.4.1 → 1.4.2
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/.circleci/config.yml +5 -3
- data/.rubocop.yml +20 -4
- data/Dockerfile +8 -4
- data/README.md +1 -1
- data/config/yardstick.yml +10 -35
- data/lib/sinclair.rb +87 -18
- data/lib/sinclair/config.rb +3 -0
- data/lib/sinclair/config/methods_builder.rb +15 -1
- data/lib/sinclair/config_builder.rb +1 -0
- data/lib/sinclair/config_class.rb +1 -0
- data/lib/sinclair/config_factory.rb +15 -0
- data/lib/sinclair/configurable.rb +1 -0
- data/lib/sinclair/matchers.rb +20 -6
- data/lib/sinclair/matchers/add_class_method.rb +56 -0
- data/lib/sinclair/matchers/add_class_method_to.rb +98 -0
- data/lib/sinclair/matchers/add_instance_method.rb +85 -0
- data/lib/sinclair/matchers/add_instance_method_to.rb +119 -0
- data/lib/sinclair/matchers/add_method.rb +11 -73
- data/lib/sinclair/matchers/add_method_to.rb +13 -111
- data/lib/sinclair/method_definition.rb +18 -58
- data/lib/sinclair/method_definition/block_definition.rb +37 -6
- data/lib/sinclair/method_definition/class_block_definition.rb +22 -0
- data/lib/sinclair/method_definition/class_method_definition.rb +50 -0
- data/lib/sinclair/method_definition/class_string_definition.rb +24 -0
- data/lib/sinclair/method_definition/instance_block_definition.rb +22 -0
- data/lib/sinclair/method_definition/instance_method_definition.rb +48 -0
- data/lib/sinclair/method_definition/instance_string_definition.rb +24 -0
- data/lib/sinclair/method_definition/string_definition.rb +39 -5
- data/lib/sinclair/method_definitions.rb +28 -0
- data/lib/sinclair/options_parser.rb +5 -0
- data/lib/sinclair/version.rb +1 -1
- data/sinclair.gemspec +16 -10
- data/spec/integration/yard/sinclair/matchers/add_class_method_spec.rb +23 -0
- data/spec/integration/yard/sinclair/matchers/add_class_method_to_spec.rb +19 -0
- data/spec/integration/yard/sinclair/matchers/{add_method_spec.rb → add_instance_method_spec.rb} +3 -3
- data/spec/integration/yard/sinclair/matchers/{add_method_to_spec.rb → add_instance_method_to_spec.rb} +1 -1
- data/spec/integration/yard/sinclair/method_definition/class_block_definition_spec.rb +34 -0
- data/spec/integration/yard/sinclair/method_definition/class_method_definition_spec.rb +28 -0
- data/spec/integration/yard/sinclair/method_definition/class_string_definition_spec.rb +23 -0
- data/spec/integration/yard/sinclair/method_definition/{block_definition_spec.rb → instance_block_definition_spec.rb} +2 -2
- data/spec/integration/yard/sinclair/method_definition/instance_method_definition_spec.rb +35 -0
- data/spec/integration/yard/sinclair/method_definition/{string_definition_spec.rb → instance_string_definition_spec.rb} +1 -1
- data/spec/integration/yard/sinclair_spec.rb +32 -5
- data/spec/lib/sinclair/matchers/add_class_method_spec.rb +36 -0
- data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +77 -0
- data/spec/lib/sinclair/matchers/{add_method_spec.rb → add_instance_method_spec.rb} +11 -4
- data/spec/lib/sinclair/matchers/{add_method_to_spec.rb → add_instance_method_to_spec.rb} +2 -2
- data/spec/lib/sinclair/matchers_spec.rb +17 -2
- data/spec/lib/sinclair/method_definition/class_block_definition_spec.rb +29 -0
- data/spec/lib/sinclair/method_definition/class_string_definition_spec.rb +27 -0
- data/spec/lib/sinclair/method_definition/{block_definition_spec.rb → instance_block_definition_spec.rb} +2 -2
- data/spec/lib/sinclair/method_definition/{string_definition_spec.rb → instance_string_definition_spec.rb} +2 -2
- data/spec/lib/sinclair/method_definition_spec.rb +52 -6
- data/spec/lib/sinclair_spec.rb +83 -0
- data/spec/support/models/dummy_class_builder.rb +11 -0
- data/spec/support/shared_examples/class_method_definition.rb +96 -0
- data/spec/support/shared_examples/{method_definition.rb → instance_method_definition.rb} +0 -0
- metadata +148 -45
- data/scripts/check_readme.sh +0 -6
- data/scripts/rubycritic.sh +0 -10
- data/spec/integration/sinclair/matchers_spec.rb +0 -99
- data/spec/integration/yard/sinclair/method_definition_spec.rb +0 -56
data/lib/sinclair/matchers.rb
CHANGED
@@ -28,17 +28,31 @@ class Sinclair
|
|
28
28
|
# end
|
29
29
|
# end
|
30
30
|
module Matchers
|
31
|
-
autoload :AddMethod,
|
32
|
-
autoload :
|
31
|
+
autoload :AddMethod, 'sinclair/matchers/add_method'
|
32
|
+
autoload :AddInstanceMethod, 'sinclair/matchers/add_instance_method'
|
33
|
+
autoload :AddClassMethod, 'sinclair/matchers/add_class_method'
|
34
|
+
autoload :AddMethodTo, 'sinclair/matchers/add_method_to'
|
35
|
+
autoload :AddInstanceMethodTo, 'sinclair/matchers/add_instance_method_to'
|
36
|
+
autoload :AddClassMethodTo, 'sinclair/matchers/add_class_method_to'
|
33
37
|
|
34
|
-
# DSL to
|
38
|
+
# DSL to AddInstanceMethod
|
35
39
|
#
|
36
40
|
# @example (see Sinclair::Matchers)
|
37
|
-
# @example (see Sinclair::Matchers::
|
41
|
+
# @example (see Sinclair::Matchers::AddInstanceMethod#to)
|
38
42
|
#
|
39
|
-
# @return [
|
43
|
+
# @return [AddInstanceMethod] RSpec Matcher
|
40
44
|
def add_method(method)
|
41
|
-
Sinclair::Matchers::
|
45
|
+
Sinclair::Matchers::AddInstanceMethod.new(method)
|
46
|
+
end
|
47
|
+
|
48
|
+
# DSL to AddClassMethod
|
49
|
+
#
|
50
|
+
# @example (see Sinclair::Matchers)
|
51
|
+
# @example (see Sinclair::Matchers::AddClassMethod#to)
|
52
|
+
#
|
53
|
+
# @return [AddClassMethod] RSpec Matcher
|
54
|
+
def add_class_method(method)
|
55
|
+
Sinclair::Matchers::AddClassMethod.new(method)
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Sinclair
|
4
|
+
module Matchers
|
5
|
+
# @api private
|
6
|
+
# @author darthjee
|
7
|
+
#
|
8
|
+
# AddClassMethod is able to build an instance of {Sinclair::Matchers::AddClassMethodTo}
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# RSpec.configure do |config|
|
12
|
+
# config.include Sinclair::Matchers
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# class MyModel
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# RSpec.describe 'MyBuilder' do
|
19
|
+
# let(:clazz) { Class.new(MyModel) }
|
20
|
+
#
|
21
|
+
# let(:block) do
|
22
|
+
# proc do
|
23
|
+
# clazz.define_singleton_method(:new_method) { 2 }
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# it do
|
28
|
+
# expect(&block).to add_class_method(:new_method).to(clazz)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # outputs
|
33
|
+
# # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
|
34
|
+
class AddClassMethod < AddMethod
|
35
|
+
# @abstract
|
36
|
+
#
|
37
|
+
# Raise a warning on the usage as this is only a builder for AddClassMethodTo
|
38
|
+
#
|
39
|
+
# @raise SyntaxError
|
40
|
+
def matches?(_actual)
|
41
|
+
raise SyntaxError, 'You should specify which class the method is being added to' \
|
42
|
+
"add_class_method(:#{method}).to(klass)"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates a matcher {AddClassMethodTo}
|
46
|
+
#
|
47
|
+
# @param target [Class]
|
48
|
+
# class where the method should be added to
|
49
|
+
#
|
50
|
+
# @return [AddClassMethodTo] the correct matcher
|
51
|
+
def to(target = nil)
|
52
|
+
AddClassMethodTo.new(target, method)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Sinclair
|
4
|
+
module Matchers
|
5
|
+
# @api private
|
6
|
+
# @author darthjee
|
7
|
+
#
|
8
|
+
# AddClassMethodTo checks whether a method was
|
9
|
+
# or not added to a class by the call of a block
|
10
|
+
#
|
11
|
+
# This is used with a RSpec DSL method
|
12
|
+
# add_class_method(method_name).to(class_object)
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# RSpec.configure do |config|
|
16
|
+
# config.include Sinclair::Matchers
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# class MyModel
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# describe 'my test' do
|
23
|
+
# let(:klass) { Class.new(MyModel) }
|
24
|
+
#
|
25
|
+
# let(:block) do
|
26
|
+
# proc do
|
27
|
+
# klass.define_singleton_method(:parent_name) { superclass.name }
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# it do
|
32
|
+
# expect(&block).to add_class_method(:parent_name).to(klass)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
class AddClassMethodTo < AddMethodTo
|
36
|
+
# @param [Class] klass
|
37
|
+
# Class where the class method should be added to
|
38
|
+
#
|
39
|
+
# @param method [SYmbol,String] method name
|
40
|
+
def initialize(klass, method)
|
41
|
+
@klass = klass
|
42
|
+
super(method)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Return expectaton description
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
def description
|
49
|
+
"add method class_method '#{method}' to #{klass}"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns message on expectation failure
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
def failure_message_for_should
|
56
|
+
"expected class_method '#{method}' to be added to #{klass} but " \
|
57
|
+
"#{@initial_state ? 'it already existed' : "it didn't"}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns message on expectation failure for negative expectation
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
def failure_message_for_should_not
|
64
|
+
"expected class_method '#{method}' not to be added to #{klass} but it was"
|
65
|
+
end
|
66
|
+
|
67
|
+
alias failure_message failure_message_for_should
|
68
|
+
alias failure_message_when_negated failure_message_for_should_not
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
# @method klass
|
73
|
+
# @private
|
74
|
+
#
|
75
|
+
# Class where class method should be added to
|
76
|
+
#
|
77
|
+
# @return [Class]
|
78
|
+
attr_reader :klass
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# Checks if class has instance method defined
|
83
|
+
#
|
84
|
+
# @return [Boolean]
|
85
|
+
def method_defined?
|
86
|
+
klass.methods(false).include?(method.to_sym)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Raises when block was not given
|
90
|
+
#
|
91
|
+
# @raise SyntaxError
|
92
|
+
def raise_block_syntax_error
|
93
|
+
raise SyntaxError, 'Block not received by the `add_class_method_to` matcher. ' \
|
94
|
+
'Perhaps you want to use `{ ... }` instead of do/end?'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Sinclair
|
4
|
+
module Matchers
|
5
|
+
# @api private
|
6
|
+
# @author darthjee
|
7
|
+
#
|
8
|
+
# AddInstanceMethod is able to build an instance of {Sinclair::Matchers::AddInstanceMethodTo}
|
9
|
+
#
|
10
|
+
# @example Using inside RSpec and checking Class
|
11
|
+
# RSpec.configure do |config|
|
12
|
+
# config.include Sinclair::Matchers
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# class MyModel
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# RSpec.describe "MyBuilder" do
|
19
|
+
# let(:clazz) { Class.new(MyModel) }
|
20
|
+
# let(:builder) { Sinclair.new(clazz) }
|
21
|
+
#
|
22
|
+
# before do
|
23
|
+
# builder.add_method(:new_method, "2")
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# it do
|
27
|
+
# expect { builder.build }.to add_method(:new_method).to(clazz)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # Outputs
|
32
|
+
# # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
|
33
|
+
#
|
34
|
+
# @example Using inside RSpec and checking instance
|
35
|
+
# RSpec.configure do |config|
|
36
|
+
# config.include Sinclair::Matchers
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# class MyModel
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# RSpec.describe "MyBuilder" do
|
43
|
+
# let(:clazz) { Class.new(MyModel) }
|
44
|
+
# let(:builder) { Sinclair.new(clazz) }
|
45
|
+
# let(:instance) { clazz.new }
|
46
|
+
#
|
47
|
+
# before do
|
48
|
+
# builder.add_method(:the_method, "true")
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# it do
|
52
|
+
# expect { builder.build }.to add_method(:the_method).to(instance)
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# # Outputs
|
57
|
+
# # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
|
58
|
+
class AddInstanceMethod < AddMethod
|
59
|
+
# @abstract
|
60
|
+
#
|
61
|
+
# Raise a warning on the usage as this is only a builder for {AddInstanceMethodTo}
|
62
|
+
#
|
63
|
+
# @raise SyntaxError
|
64
|
+
def matches?(_actual)
|
65
|
+
raise SyntaxError, 'You should specify which instance the method is being added to' \
|
66
|
+
"add_method(:#{method}).to(instance)"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Creates a matcher AddInstanceMethodTo
|
70
|
+
#
|
71
|
+
# @overload to(klass)
|
72
|
+
# @param [Class] klass
|
73
|
+
# class where the method should be added to
|
74
|
+
#
|
75
|
+
# @overload to(instance)
|
76
|
+
# @param [Object] instance
|
77
|
+
# instance of the class where the method should be added to
|
78
|
+
#
|
79
|
+
# @return [AddInstanceMethodTo] the correct matcher
|
80
|
+
def to(target = nil)
|
81
|
+
AddInstanceMethodTo.new(target, method)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Sinclair
|
4
|
+
module Matchers
|
5
|
+
# @api private
|
6
|
+
# @author darthjee
|
7
|
+
#
|
8
|
+
# AddInstanceMethodTo checks whether a method was or not added by the call of a block
|
9
|
+
#
|
10
|
+
# This is used with a RSpec DSL method add_method(method_name).to(class_object)
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# RSpec.configure do |config|
|
14
|
+
# config.include Sinclair::Matchers
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# class MyModel
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# RSpec.describe 'my test' do
|
21
|
+
# let(:klass) { Class.new(MyModel) }
|
22
|
+
# let(:builder) { Sinclair.new(klass) }
|
23
|
+
#
|
24
|
+
# before do
|
25
|
+
# builder.add_method(:class_name, 'self.class.name')
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# it do
|
29
|
+
# expect { builder.build }.to add_method(:class_name).to(klass)
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
class AddInstanceMethodTo < AddMethodTo
|
33
|
+
# Returns a new instance of AddInstanceMethodTo
|
34
|
+
#
|
35
|
+
# @overload initialize(klass, method)
|
36
|
+
# @param [Class] klass
|
37
|
+
# class where the method should be added to
|
38
|
+
#
|
39
|
+
# @overload initialize(instance, method)
|
40
|
+
# @param [Object] instance
|
41
|
+
# instance of the class where the method should be added to
|
42
|
+
#
|
43
|
+
# @param method [Symbol,String] method name
|
44
|
+
def initialize(target, method)
|
45
|
+
if target.is_a?(Class)
|
46
|
+
@klass = target
|
47
|
+
else
|
48
|
+
@instance = target
|
49
|
+
end
|
50
|
+
super(method)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returnst expectaton description
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
def description
|
57
|
+
"add method '#{method}' to #{klass} instances"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns message on expectation failure
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
def failure_message_for_should
|
64
|
+
"expected '#{method}' to be added to #{klass} but " \
|
65
|
+
"#{@initial_state ? 'it already existed' : "it didn't"}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns message on expectation failure for negative expectation
|
69
|
+
#
|
70
|
+
# @return [String]
|
71
|
+
def failure_message_for_should_not
|
72
|
+
"expected '#{method}' not to be added to #{klass} but it was"
|
73
|
+
end
|
74
|
+
|
75
|
+
alias failure_message failure_message_for_should
|
76
|
+
alias failure_message_when_negated failure_message_for_should_not
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
# @method instance
|
81
|
+
# @private
|
82
|
+
#
|
83
|
+
# Instance of the class where the method should be added
|
84
|
+
#
|
85
|
+
# @return [Object]
|
86
|
+
attr_reader :instance
|
87
|
+
|
88
|
+
# @private
|
89
|
+
#
|
90
|
+
# Class to be analised
|
91
|
+
#
|
92
|
+
# @return [Class]
|
93
|
+
def klass
|
94
|
+
@klass ||= instance.class
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
# @private
|
100
|
+
#
|
101
|
+
# Checks if class has instance method defined
|
102
|
+
#
|
103
|
+
# @return [Boolean]
|
104
|
+
def method_defined?
|
105
|
+
klass.method_defined?(method)
|
106
|
+
end
|
107
|
+
|
108
|
+
# @private
|
109
|
+
#
|
110
|
+
# Raises when block was not given
|
111
|
+
#
|
112
|
+
# @raise SyntaxError
|
113
|
+
def raise_block_syntax_error
|
114
|
+
raise SyntaxError, 'Block not received by the `add_instance_method_to` matcher. ' \
|
115
|
+
'Perhaps you want to use `{ ... }` instead of do/end?'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -2,82 +2,17 @@
|
|
2
2
|
|
3
3
|
class Sinclair
|
4
4
|
module Matchers
|
5
|
+
# @api private
|
5
6
|
# @author darthjee
|
6
|
-
#
|
7
|
+
# @abstract
|
8
|
+
#
|
9
|
+
# Base class for add_method matcher
|
7
10
|
class AddMethod < RSpec::Matchers::BuiltIn::BaseMatcher
|
8
|
-
# @api private
|
9
|
-
# @abstract
|
10
|
-
#
|
11
|
-
# Raise a warning on the usage as this is only a builder for AddMethodTo
|
12
|
-
#
|
13
|
-
# @raise SyntaxError
|
14
|
-
def matches?(_actual)
|
15
|
-
raise SyntaxError, 'You should specify which instance the method is being added to' \
|
16
|
-
"add_method(:#{method}).to(instance)"
|
17
|
-
end
|
18
|
-
|
19
|
-
# @api private
|
20
|
-
#
|
21
|
-
# Returns a new instance of AddMethod
|
22
|
-
#
|
23
11
|
# @param method [String,Symbol] the method, to be checked, name
|
24
12
|
def initialize(method)
|
25
|
-
@method = method
|
26
|
-
end
|
27
|
-
|
28
|
-
# @api public
|
29
|
-
#
|
30
|
-
# Creates a matcher AddMethodTo
|
31
|
-
#
|
32
|
-
# @overload to(klass)
|
33
|
-
# @param [Class] klass
|
34
|
-
# class where the method should be added to
|
35
|
-
#
|
36
|
-
# @overload to(instance)
|
37
|
-
# @param [Object] instance
|
38
|
-
# instance of the class where the method should be added to
|
39
|
-
#
|
40
|
-
# @example Using inside RSpec and checking Class
|
41
|
-
# RSpec.describe "MyBuilder" do
|
42
|
-
# let(:clazz) { Class.new }
|
43
|
-
# let(:builder) { Sinclair.new(clazz) }
|
44
|
-
#
|
45
|
-
# before do
|
46
|
-
# builder.add_method(:new_method, "2")
|
47
|
-
# end
|
48
|
-
#
|
49
|
-
# it do
|
50
|
-
# expect { builder.build }.to add_method(:new_method).to(clazz)
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# # Outputs
|
55
|
-
# # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
|
56
|
-
# @example Using inside RSpec and checking instance
|
57
|
-
# RSpec.describe "MyBuilder" do
|
58
|
-
# let(:clazz) { Class.new }
|
59
|
-
# let(:builder) { Sinclair.new(clazz) }
|
60
|
-
# let(:instance) { clazz.new }
|
61
|
-
#
|
62
|
-
# before do
|
63
|
-
# builder.add_method(:the_method, "true")
|
64
|
-
# end
|
65
|
-
#
|
66
|
-
# it do
|
67
|
-
# expect { builder.build }.to add_method(:the_method).to(instance)
|
68
|
-
# end
|
69
|
-
# end
|
70
|
-
#
|
71
|
-
# # Outputs
|
72
|
-
# # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
|
73
|
-
#
|
74
|
-
# @return [AddMethodTo] the correct matcher
|
75
|
-
def to(target = nil)
|
76
|
-
AddMethodTo.new(target, method)
|
13
|
+
@method = method.to_sym
|
77
14
|
end
|
78
15
|
|
79
|
-
# @api private
|
80
|
-
#
|
81
16
|
# definition needed for block matchers
|
82
17
|
#
|
83
18
|
# @return [Boolean]
|
@@ -85,13 +20,12 @@ class Sinclair
|
|
85
20
|
true
|
86
21
|
end
|
87
22
|
|
88
|
-
# @api private
|
89
|
-
#
|
90
23
|
# Checkes if another instnce is equal self
|
91
24
|
#
|
92
25
|
# @return [Boolean]
|
93
26
|
def equal?(other)
|
94
27
|
return unless other.class == self.class
|
28
|
+
|
95
29
|
other.method == method
|
96
30
|
end
|
97
31
|
|
@@ -99,8 +33,12 @@ class Sinclair
|
|
99
33
|
|
100
34
|
protected
|
101
35
|
|
102
|
-
# @
|
36
|
+
# @method method
|
103
37
|
# @private
|
38
|
+
#
|
39
|
+
# The method, to be checked, name
|
40
|
+
#
|
41
|
+
# @return [Symbol]
|
104
42
|
attr_reader :method
|
105
43
|
end
|
106
44
|
end
|