Class: Hardmock::Expector

Inherits:
Object show all
Includes:
MethodCleanout
Defined in:
lib/hardmock/expector.rb

Overview

:nodoc:

Constant Summary

Constants included from MethodCleanout

MethodCleanout::SACRED_METHODS

Instance Method Summary collapse

Methods included from MethodCleanout

included

Constructor Details

#initialize(mock, mock_control, expectation_builder) ⇒ Expector

Returns a new instance of Expector.



8
9
10
11
12
# File 'lib/hardmock/expector.rb', line 8

def initialize(mock,mock_control,expectation_builder)
  @mock = mock
  @mock_control = mock_control
  @expectation_builder = expectation_builder
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mname, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/hardmock/expector.rb', line 14

def method_missing(mname, *args, &block)
  expectation = @expectation_builder.build_expectation(
    :mock => @mock, 
    :method => mname, 
    :arguments => args, 
    :block => block)

  @mock_control.add_expectation expectation
  expectation
end