Class: RSpec::Matchers::DelegateMatcher::Delegate
- Inherits:
-
Object
- Object
- RSpec::Matchers::DelegateMatcher::Delegate
- Includes:
- Block
- Defined in:
- lib/delegate_matcher/delegate.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#received ⇒ Object
readonly
Returns the value of attribute received.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes included from Block
Instance Method Summary collapse
- #argument_description ⇒ Object
-
#initialize(expected, to) ⇒ Delegate
constructor
A new instance of Delegate.
-
#receiver ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods included from Block
Constructor Details
#initialize(expected, to) ⇒ Delegate
Returns a new instance of Delegate.
11 12 13 14 15 |
# File 'lib/delegate_matcher/delegate.rb', line 11 def initialize(expected, to) self.expected = expected self.to = to self.received = false end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
9 10 11 |
# File 'lib/delegate_matcher/delegate.rb', line 9 def args @args end |
#received ⇒ Object
Returns the value of attribute received.
9 10 11 |
# File 'lib/delegate_matcher/delegate.rb', line 9 def received @received end |
#to ⇒ Object
Returns the value of attribute to.
9 10 11 |
# File 'lib/delegate_matcher/delegate.rb', line 9 def to @to end |
Instance Method Details
#argument_description ⇒ Object
36 37 38 |
# File 'lib/delegate_matcher/delegate.rb', line 36 def argument_description args ? "(#{args.map(&:inspect).join(', ')})" : '' end |
#receiver ⇒ Object
rubocop:disable Metrics/AbcSize
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/delegate_matcher/delegate.rb', line 18 def receiver klass = subject.class @receiver ||= case when a_class_variable? klass.class_variable_get(name) when an_instance_variable? subject.instance_variable_get(name) when a_constant? klass.const_get(name) when a_method? subject.send(name) when a_reference? subject.instance_eval(name) else # is an object to end end |