module RSpec::Matchers::DSL::DefaultImplementations

Defines default implementations of the matcher protocol methods for custom matchers. You can override any of these using the {RSpec::Matchers::DSL::Macros Macros} methods from within an ‘RSpec::Matchers.define` block.

Public Instance Methods

description() click to toggle source

The default description.

# File lib/rspec/matchers/dsl.rb, line 394
def description
  english_name = EnglishPhrasing.split_words(name)
  expected_list = EnglishPhrasing.list(expected)
  "#{english_name}#{expected_list}#{chained_method_clause_sentences}"
end
diffable?() click to toggle source

@api private Used internally by objects returns by ‘should` and `should_not`.

# File lib/rspec/matchers/dsl.rb, line 389
def diffable?
  false
end
expects_call_stack_jump?() click to toggle source

Most matchers do not expect call stack jumps.

# File lib/rspec/matchers/dsl.rb, line 411
def expects_call_stack_jump?
  false
end
supports_block_expectations?() click to toggle source

Matchers do not support block expectations by default. You must opt-in.

# File lib/rspec/matchers/dsl.rb, line 402
def supports_block_expectations?
  false
end
supports_value_expectations?() click to toggle source
# File lib/rspec/matchers/dsl.rb, line 406
def supports_value_expectations?
  true
end

Private Instance Methods

chained_method_clause_sentences() click to toggle source
# File lib/rspec/matchers/dsl.rb, line 417
def chained_method_clause_sentences
  return '' unless Expectations.configuration.include_chain_clauses_in_custom_matcher_descriptions?

  @chained_method_clauses.map do |(method_name, method_args)|
    english_name = EnglishPhrasing.split_words(method_name)
    arg_list = EnglishPhrasing.list(method_args)
    " #{english_name}#{arg_list}"
  end.join
end