Class: RR::Adapters::Rspec::InvocationMatcher

Inherits:
SpyVerificationProxy show all
Defined in:
lib/rr/adapters/rspec.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (InvocationMatcher) initialize(method = nil)

Returns a new instance of InvocationMatcher



29
30
31
32
33
# File 'lib/rr/adapters/rspec.rb', line 29

def initialize(method = nil)
  @verification = nil
  @subject = nil
  method_missing(method) if method
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_name, *args, &block)



50
51
52
53
54
55
56
57
# File 'lib/rr/adapters/rspec.rb', line 50

def method_missing(method_name, *args, &block)
  if @verification
    @verification.send(method_name, *args)
  else
    @verification = super
  end
  self
end

Instance Attribute Details

- (Object) failure_message (readonly)

Returns the value of attribute failure_message



27
28
29
# File 'lib/rr/adapters/rspec.rb', line 27

def failure_message
  @failure_message
end

- (Object) spy_verification_proxy (readonly)

Returns the value of attribute spy_verification_proxy



27
28
29
# File 'lib/rr/adapters/rspec.rb', line 27

def spy_verification_proxy
  @spy_verification_proxy
end

Instance Method Details

- (Boolean) matches?(subject)

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
# File 'lib/rr/adapters/rspec.rb', line 35

def matches?(subject)
  @verification.subject = subject
  calls = RR::Space.instance.recorded_calls
  if error = calls.match_error(@verification)
    @failure_message = error.message
    false
  else
    true
  end
end

- (Boolean) nil?

Returns:

  • (Boolean)


46
47
48
# File 'lib/rr/adapters/rspec.rb', line 46

def nil?
  false
end