class ContainsText

Public Class Methods

new(expected) click to toggle source

this is what the matcher is called on. In this case:

foo.should contains(:bars)

foo would be passed to the initialize

# File lib/rwebspec-common/matchers/contains_text.rb, line 7
def initialize(expected)
  @expected = expected
end

Public Instance Methods

actual_text() click to toggle source
# File lib/rwebspec-common/matchers/contains_text.rb, line 16
def actual_text
  @actual.to_s.length > 256 ? @actual[0, 255] : @actual
end
failure_message() click to toggle source

error message for should

# File lib/rwebspec-common/matchers/contains_text.rb, line 21
def failure_message
  "expected '#{actual_text}' to contain '#{@expected}', but it didn't"
end
matches?(actual) click to toggle source
# File lib/rwebspec-common/matchers/contains_text.rb, line 11
def matches?(actual)
  @actual = actual
  return actual && actual.include?(@expected)
end
negative_failure_message() click to toggle source

error message for should_not

# File lib/rwebspec-common/matchers/contains_text.rb, line 26
def negative_failure_message
  "expected '#{actual_text}' not to contain '#{@expected}', but it did"
end