Class: DuckTyper::CanonicalInterfaceChecker::Result

Inherits:
Object
  • Object
show all
Includes:
ResultFormatting
Defined in:
lib/duck_typer/canonical_interface_checker/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(canonical:, results:, name:, strict:) ⇒ Result

Returns a new instance of Result.



10
11
12
13
14
15
# File 'lib/duck_typer/canonical_interface_checker/result.rb', line 10

def initialize(canonical:, results:, name:, strict:)
  @canonical = canonical
  @results = results
  @name = name
  @strict = strict
end

Instance Method Details

#failure_messageObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/duck_typer/canonical_interface_checker/result.rb', line 21

def failure_message
  return if match?

  failing = @results.reject(&:match?)

  <<~MSG
    Expected all objects to implement compatible \
    #{interface_label} defined by #{@canonical}, \
    but the following method signatures differ:#{strict_note}

    #{failing.map(&:diff_message).join("\n")}
  MSG
end

#match?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/duck_typer/canonical_interface_checker/result.rb', line 17

def match?
  @results.all?(&:match?)
end