class Capybara::RSpecMatchers::HaveMatcher

Attributes

actual[R]
failure_message[R]
locator[R]
name[R]
options[R]

Public Class Methods

new(name, locator, options={}, &block) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 56
def initialize(name, locator, options={}, &block)
  @name = name
  @locator = locator
  @options = options
  @failure_message = block
end

Public Instance Methods

arguments() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 63
def arguments
  if options.empty? then [locator] else [locator, options] end
end
description() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 89
def description
  "has #{selector_name}"
end
does_not_match?(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 72
def does_not_match?(actual)
  @actual = wrap(actual)
  @actual.send(:"has_no_#{name}?", *arguments)
end
failure_message_for_should() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 77
def failure_message_for_should
  if failure_message
    failure_message.call(actual, self)
  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 85
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 67
def matches?(actual)
  @actual = wrap(actual)
  @actual.send(:"has_#{name}?", *arguments)
end
selector_name() click to toggle source
# File lib/capybara/rspec/matchers.rb, line 93
def selector_name
  selector_name = "#{name} #{locator.inspect}"
  selector_name << " with text #{options[:text].inspect}" if options[:text]
  selector_name
end
wrap(actual) click to toggle source
# File lib/capybara/rspec/matchers.rb, line 99
def wrap(actual)
  if actual.respond_to?("has_selector?")
    actual
  else
    Capybara.string(actual.to_s)
  end
end