Class: TarkaMatchers::Matchers::Expectation::HaveADescriptionOf

Inherits:
Object
  • Object
show all
Includes:
Helpers::Expectation::Common
Defined in:
lib/tarka_matchers/matchers/expectation/have_a_description_of.rb

Constant Summary

Constants included from Helpers::Expectation::Common

Helpers::Expectation::Common::NEWLINE, Helpers::Expectation::Common::SGR

Instance Method Summary collapse

Methods included from Helpers::Expectation::Common

#clean!

Constructor Details

#initialize(expected) ⇒ HaveADescriptionOf

Returns a new instance of HaveADescriptionOf.



13
14
15
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 13

def initialize expected
	@expected = expected
end

Instance Method Details

#descriptionObject



29
30
31
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 29

def description	
	"utilize a matcher that has a description of: '#{@expected}'"
end

#failure_messageObject



33
34
35
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 33

def failure_message
	"The matcher, '#{@actual_matcher.class}', does not have the expected description: #{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}"
end

#failure_message_when_negatedObject



37
38
39
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 37

def failure_message_when_negated
	"#{description}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 21

def matches? actual
	captured = TarkaMatchers::Helpers::Expectation::ExpectCapture.capture(actual)
	@actual_matcher = captured[1]
	@actual = escape(@actual_matcher.description.prepend captured[0])
	clean!(@actual)
	@actual == @expected
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tarka_matchers/matchers/expectation/have_a_description_of.rb', line 17

def supports_block_expectations?
	true
end