Class: RSpec::Matchers::DelegateMatcher::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/delegate_matcher/dispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Dispatcher

Returns a new instance of Dispatcher.



7
8
9
# File 'lib/delegate_matcher/dispatcher.rb', line 7

def initialize(expected)
  self.expected = expected
end

Instance Attribute Details

#return_valueObject

Returns the value of attribute return_value.



5
6
7
# File 'lib/delegate_matcher/dispatcher.rb', line 5

def return_value
  @return_value
end

Instance Method Details

#blockObject



18
19
20
# File 'lib/delegate_matcher/dispatcher.rb', line 18

def block
  @block ||= expected.block.is_a?(Proc) ? expected.block : proc {}
end

#callObject



11
12
13
14
15
16
# File 'lib/delegate_matcher/dispatcher.rb', line 11

def call
  args = expected.args
  args = [] if args && args[0].is_a?(Mocks::ArgumentMatchers::NoArgsMatcher)

  self.return_value = expected.subject.send(expected.delegator_method_name, *args, &block)
end