class Capybara::RSpecMatchers::HaveText

Attributes

content[R]
failure_message[R]
failure_message_for_should[R]
failure_message_for_should_not[R]
failure_message_when_negated[R]
options[R]
type[R]

Public Class Methods

new(*args) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 54
def initialize(*args)
  @args = args.dup

  # are set just for backwards compatability
  @type = args.shift if args.first.is_a?(Symbol)
  @content = args.shift
  @options = (args.first.is_a?(Hash))? args.first : {}
end

Public Instance Methods

description() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 77
def description
  "text #{format(content)}"
end
does_not_match?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 70
def does_not_match?(actual)
  wrap(actual).assert_no_text(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message_when_negated = e.message
  return false
end
format(content) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 81
def format(content)
  content = Capybara::Helpers.normalize_whitespace(content) unless content.is_a? Regexp
  content.inspect
end
matches?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 63
def matches?(actual)
  wrap(actual).assert_text(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message = e.message
  return false
end