Class: Spec::Rails::Matchers::IncludeText

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ IncludeText

Returns a new instance of IncludeText.



7
8
9
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb', line 7

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



24
25
26
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb', line 24

def description
  "include text #{expected.inspect}"
end

#failure_message_for_shouldObject



16
17
18
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb', line 16

def failure_message_for_should
  "expected to find #{expected.inspect} in #{actual.inspect}"
end

#failure_message_for_should_notObject



20
21
22
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb', line 20

def failure_message_for_should_not
  "expected not to include text #{expected.inspect}"
end

#matches?(response_or_text) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb', line 11

def matches?(response_or_text)
  @actual = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text
  return actual.include?(expected)
end