Class: Moarspec::Matchers::Not
- Inherits:
-
RSpec::Matchers::BuiltIn::BaseMatcher
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- Moarspec::Matchers::Not
show all
- Defined in:
- lib/moarspec/matchers/dont.rb
Defined Under Namespace
Classes: Delegator
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Not
Returns a new instance of Not.
7
8
9
10
|
# File 'lib/moarspec/matchers/dont.rb', line 7
def initialize(*)
super
@delegator = Delegator.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/moarspec/matchers/dont.rb', line 39
def method_missing(m, *a, &)
if @matcher
@matcher.send(m, *a, &)
else
@matcher = @delegator.send(m, *a, &)
end
self
end
|
Instance Method Details
#description ⇒ Object
12
13
14
|
# File 'lib/moarspec/matchers/dont.rb', line 12
def description
"not #{@matcher.description}"
end
|
#failure_message ⇒ Object
31
32
33
|
# File 'lib/moarspec/matchers/dont.rb', line 31
def failure_message
@matcher.failure_message_when_negated
end
|
#match(_expected, actual) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/moarspec/matchers/dont.rb', line 16
def match(_expected, actual)
@matcher or fail ArgumentError, '`dont` matcher used without any matcher to negate. ' \
'Usage: dont.other_matcher(args)'
if @matcher.respond_to?(:does_not_match?)
@matcher.does_not_match?(actual)
else
!@matcher.matches?(actual)
end
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
49
50
51
52
53
54
55
|
# File 'lib/moarspec/matchers/dont.rb', line 49
def respond_to_missing?(method, include_private = false)
if @matcher
@matcher.respond_to?(method, include_private)
else
@delegator.respond_to_missing?(method, include_private)
end
end
|
#supports_block_expectations? ⇒ Boolean
35
36
37
|
# File 'lib/moarspec/matchers/dont.rb', line 35
def supports_block_expectations?
@matcher.supports_block_expectations?
end
|
#with ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/moarspec/matchers/dont.rb', line 62
def with(...)
if @matcher
@matcher.with(...)
else
@matcher = @delegator.with(...)
end
self
end
|