Class: DuckTesting::Tester

Inherits:
Object
  • Object
show all
Defined in:
lib/duck_testing/tester.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver, method_name) ⇒ Tester

Returns a new instance of Tester.

Parameters:

  • receiver (Object)

    the receiver object.

  • method_name (String)

    the invoked method's name.



7
8
9
# File 'lib/duck_testing/tester.rb', line 7

def initialize(receiver, method_name)
  @call_data = MethodCallData.new(receiver, method_name)
end

Instance Attribute Details

#call_dataObject (readonly)

Returns the value of attribute call_data.



3
4
5
# File 'lib/duck_testing/tester.rb', line 3

def call_data
  @call_data
end

Instance Method Details

#match?(param, expected_types) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/duck_testing/tester.rb', line 28

def match?(param, expected_types)
  expected_types.any? do |type|
    type.match?(param)
  end
end

#test_param(param, expected_types) ⇒ Object

Parameters:



13
14
15
# File 'lib/duck_testing/tester.rb', line 13

def test_param(param, expected_types)
  test(param, expected_types, :param)
end

#test_return(param, expected_types) ⇒ Object

Parameters:

Returns:

  • (Object)


20
21
22
23
# File 'lib/duck_testing/tester.rb', line 20

def test_return(param, expected_types)
  test(param, expected_types, :return)
  param
end