Class: DuckTesting::Violation

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/duck_testing/violation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call_data: nil, param: nil, expected_types: nil, param_or_return: nil) ⇒ Violation

Returns a new instance of Violation.

Parameters:

  • call_data (DuckTesting::MethodCallData) (defaults to: nil)
  • param (Object) (defaults to: nil)

    the given object.

  • expected_types (Array<DuckTesting::Type::Base>) (defaults to: nil)

    the expected object types.

  • param_or_return (Symbol) (defaults to: nil)

    the report type, :param or :return



15
16
17
18
19
20
# File 'lib/duck_testing/violation.rb', line 15

def initialize(call_data: nil, param: nil, expected_types: nil, param_or_return: nil)
  @call_data = call_data
  @param = param
  @expected_types = expected_types
  @param_or_return = param_or_return
end

Instance Attribute Details

#paramObject (readonly)

Returns the value of attribute param.



9
10
11
# File 'lib/duck_testing/violation.rb', line 9

def param
  @param
end

Instance Method Details

#expectedString

Returns:

  • (String)


33
34
35
# File 'lib/duck_testing/violation.rb', line 33

def expected
  expected_types.map(&:to_s).join(", ")
end

#param?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/duck_testing/violation.rb', line 23

def param?
  param_or_return == :param
end

#return?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/duck_testing/violation.rb', line 28

def return?
  param_or_return == :return
end