123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Matchers::DSL::DefaultImplementations

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: rspec-expectations/lib/rspec/matchers/dsl.rb

Overview

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

Instance Attribute Summary

Instance Method Summary

::RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages - Included

#failure_message

Provides a good generic failure message.

#failure_message_when_negated

Provides a good generic negative failure message.

Instance Attribute Details

#diffable?Boolean (readonly)

This method is for internal use only.

Used internally by objects returns by should and should_not.

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 390

def diffable?
  false
end

#expects_call_stack_jump?Boolean (readonly)

Most matchers do not expect call stack jumps.

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 412

def expects_call_stack_jump?
  false
end

#supports_block_expectations?Boolean (readonly)

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

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 403

def supports_block_expectations?
  false
end

#supports_value_expectations?Boolean (readonly)

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 407

def supports_value_expectations?
  true
end

Instance Method Details

#chained_method_clause_sentences (private)

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 418

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

#description

The default description.

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/dsl.rb', line 395

def description
  english_name = EnglishPhrasing.split_words(name)
  expected_list = EnglishPhrasing.list(expected)
  "#{english_name}#{expected_list}#{chained_method_clause_sentences}"
end