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

Included in:
Matcher
Defined in:
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 Method Summary (collapse)

Instance Method Details

- (Object) description

The default description.



245
246
247
# File 'lib/rspec/matchers/dsl.rb', line 245

def description
  "#{name_to_sentence}#{to_sentence expected}"
end

- (Boolean) diffable?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Used internally by objects returns by should and should_not.

Returns:

  • (Boolean)


240
241
242
# File 'lib/rspec/matchers/dsl.rb', line 240

def diffable?
  false
end

- (Object) failure_message

The default failure message for positive expectations.



250
251
252
# File 'lib/rspec/matchers/dsl.rb', line 250

def failure_message
  "expected #{actual.inspect} to #{name_to_sentence}#{to_sentence expected}"
end

- (Object) failure_message_when_negated

The default failure message for negative expectations.



255
256
257
# File 'lib/rspec/matchers/dsl.rb', line 255

def failure_message_when_negated
  "expected #{actual.inspect} not to #{name_to_sentence}#{to_sentence expected}"
end