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

#descriptionObject

The default description.



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

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

#diffable?Boolean

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)


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

def diffable?
  false
end

#failure_messageObject

The default failure message for positive expectations.



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

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

#failure_message_when_negatedObject

The default failure message for negative expectations.



261
262
263
# File 'lib/rspec/matchers/dsl.rb', line 261

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

#supports_block_expectations?Boolean

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

Returns:

  • (Boolean)


267
268
269
# File 'lib/rspec/matchers/dsl.rb', line 267

def supports_block_expectations?
  false
end