Class: RSpec::Expectations::ExpectationTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/adequack/integration/expect_syntax_support.rb

Instance Method Summary collapse

Instance Method Details

#to(matcher = nil, message = nil, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/adequack/integration/expect_syntax_support.rb', line 5

def to(matcher = nil, message = nil, &block)
  matcher_message = get_affected_message(matcher)

  if matcher.kind_of?(RSpec::Mocks::Matchers::HaveReceived) && @target.kind_of?(Adequack::RspecProxy)
    @target = @target.instance_variable_get(:"@target")
  end

  if @target.kind_of?(Adequack::RspecProxy) && matcher_message
    @target.send(
      :check_method_existence,
      matcher.instance_variable_get(:"@#{matcher_message}"))

  end

  prevent_operator_matchers(:to, matcher)
  RSpec::Expectations::PositiveExpectationHandler
    .handle_matcher(
      @target,
      matcher,
      message,
      &block
    )
end