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.



273
274
275
# File 'lib/rspec/matchers/dsl.rb', line 273

def description
  "#{name_to_sentence}#{to_sentence expected}#{chained_method_clause_sentences}"
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)


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

def diffable?
  false
end

- (Boolean) expects_call_stack_jump?

Most matchers do not expect call stack jumps.

Returns:

  • (Boolean)


294
295
296
# File 'lib/rspec/matchers/dsl.rb', line 294

def expects_call_stack_jump?
  false
end

- (Object) failure_message

The default failure message for positive expectations.



278
279
280
# File 'lib/rspec/matchers/dsl.rb', line 278

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

- (Object) failure_message_when_negated

The default failure message for negative expectations.



283
284
285
# File 'lib/rspec/matchers/dsl.rb', line 283

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

- (Boolean) supports_block_expectations?

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

Returns:

  • (Boolean)


289
290
291
# File 'lib/rspec/matchers/dsl.rb', line 289

def supports_block_expectations?
  false
end