Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Arguments

Inherits:
Base
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb

Defined Under Namespace

Modules: Commands

Instance Attribute Summary

Attributes inherited from Base

#block_expectation_value, #matcher

Instance Method Summary collapse

Methods inherited from Base

#does_not_match?, #initialize

Instance Method Details

#apply_stubs!void

This method returns an undefined value.



16
17
18
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb', line 16

def apply_stubs!
  Commands::ApplyStubToTrackDelegations.call(matcher: matcher)
end

#failure_messageString

Returns:

  • (String)


36
37
38
39
40
41
42
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb', line 36

def failure_message
  <<~MESSAGE.chomp
    #{failure_message_expected_part}

    #{failure_message_got_part}
  MESSAGE
end

#failure_message_when_negatedString

Returns:

  • (String)


47
48
49
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb', line 47

def failure_message_when_negated
  "expected `#{inputs.printable_block_expectation}` NOT to delegate to `#{inputs.printable_method}` #{printable_expected_arguments} at least once, but it did."
end

#matches?(block_expectation_value) ⇒ Boolean

Parameters:

  • block_expectation_value (Object)

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb', line 24

def matches?(block_expectation_value)
  super

  outputs.delegations.any? { |delegation| matches_arguments?(delegation.arguments) }
end

#printable_actual_argumentsString

Returns:

  • (String)


54
55
56
57
58
59
60
61
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb', line 54

def printable_actual_arguments
  return "" if outputs.delegations.none?

  outputs.delegations
    .map { |delegation| Commands::GeneratePrintableArguments.call(arguments: delegation.arguments) }
    .join(", ")
    .prepend("with ")
end