Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnDelegationValue
- Inherits:
-
Base
- Object
- Base
- ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnDelegationValue
- Defined in:
- lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb
Instance Attribute Summary
Attributes inherited from Base
#block_expectation_value, #matcher
Instance Method Summary collapse
- #failure_message ⇒ String
- #failure_message_when_negated ⇒ String
- #matches?(block_expectation_value) ⇒ Boolean
Methods inherited from Base
#apply_stubs!, #does_not_match?, #initialize
Constructor Details
This class inherits a constructor from ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Base
Instance Method Details
#failure_message ⇒ String
74 75 76 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb', line 74 def [, same_visual_output_note].reject(&:empty?).join("\n\n") end |
#failure_message_when_negated ⇒ String
81 82 83 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb', line 81 def "expected `#{inputs.printable_block_expectation}` NOT to delegate to `#{inputs.printable_method}` and return its value, but it did." end |
#matches?(block_expectation_value) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb', line 18 def matches?(block_expectation_value) super ## # TODO: `with_warmup`. # # IMPORTANT: `and_return_its_value` works only when `delegate_to` checks a pure function. # # For example (1): # def require_dependencies_pure # RequireDependenciesPure.call # end # # class RequireDependenciesPure # def self.call # dependencies.require! # # true # end # end # # # Works since `RequireDependenciesPure.call` always returns `true`. # specify do # expect { require_dependencies_pure } # .to delegate_to(RequireDependenciesPure, :call) # .and_return_its_value # end # # Example (2): # def require_dependencies_not_pure # RequireDependenciesNotPure.call # end # # class RequireDependenciesNotPure # def self.call # return false if dependencies.required? # # dependencies.require! # # true # end # end # # # Does NOT work since `RequireDependenciesNotPure.call` returns `true` for the first time and `false` for the subsequent call. # specify do # expect { require_dependencies_not_pure } # .to delegate_to(RequireDependenciesNotPure, :call) # .and_return_its_value # end # block_expectation_value == inputs.delegation_value end |