class Capybara::RSpecMatchers::HaveText

Attributes

content[R]
options[R]
type[R]

Public Class Methods

new(*args) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 38
def initialize(*args)
  @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 64
def description
  "text #{format(content)}"
end
does_not_match?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 49
def does_not_match?(actual)
  @actual = wrap(actual)
  @actual.has_no_text?(type, content, options)
end
failure_message_for_should() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 54
def failure_message_for_should
  message = Capybara::Helpers.failure_message(description, options)
  message << " in #{format(@actual.text(type))}"
  message
end
failure_message_for_should_not() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 60
def failure_message_for_should_not
  failure_message_for_should.sub(/(to find)/, 'not \1')
end
format(content) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 68
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 44
def matches?(actual)
  @actual = wrap(actual)
  @actual.has_text?(type, content, options)
end