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

Inherits:
Base
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb

Instance Attribute Summary

Attributes inherited from Base

#block_expectation_value, #matcher

Instance Method Summary collapse

Methods inherited from Base

#apply_stubs!, #does_not_match?, #initialize

Instance Method Details

#failure_messageString

Returns:

  • (String)


34
35
36
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb', line 34

def failure_message
  [failure_message_permanent_part, same_visual_output_note].reject(&:empty?).join("\n\n")
end

#failure_message_when_negatedString

Returns:

  • (String)


41
42
43
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb', line 41

def failure_message_when_negated
  "expected `#{inputs.printable_block_expectation}` NOT to delegate to `#{inputs.printable_method}` and return custom value `#{inputs.custom_return_value.inspect}`, but it did."
end

#matches?(block_expectation_value) ⇒ Boolean

Parameters:

  • block_expectation_value (Object)

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb', line 18

def matches?(block_expectation_value)
  super

  ##
  #   specify do
  #     expect { require_dependencies_not_pure }
  #       .to delegate_to(RequireDependenciesNotPure, :call)
  #       .and_return { |delegation_value| delegation_value.to_s }
  #   end
  #
  block_expectation_value == inputs.custom_return_value
end