class Capybara::RSpecMatchers::HaveSelector

Public Class Methods

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

Public Instance Methods

description() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 30
def description
  "has #{selector_name}"
end
does_not_match?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 13
def does_not_match?(actual)
  @actual = wrap(actual)
  @actual.has_no_selector?(*@args)
end
failure_message_for_should() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 18
def failure_message_for_should
  if normalized.failure_message
    normalized.failure_message.call(@actual, normalized)
  else
    "expected #{selector_name} to return something"
  end
end
failure_message_for_should_not() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 26
def failure_message_for_should_not
  "expected #{selector_name} not to return anything"
end
matches?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 8
def matches?(actual)
  @actual = wrap(actual)
  @actual.has_selector?(*@args)
end
normalized() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 48
def normalized
  @normalized ||= Capybara::Selector.normalize(*@args)
end
selector_name() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 34
def selector_name
  name = "#{normalized.name} #{normalized.locator.inspect}"
  name << " with text #{normalized.options[:text].inspect}" if normalized.options[:text]
  name
end
wrap(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 40
def wrap(actual)
  if actual.respond_to?("has_selector?")
    actual
  else
    Capybara.string(actual.to_s)
  end
end