class Spec::Rails::Matchers::AssertSelect

:nodoc:

def arg_list(*args)

def arg_list(*args)
  args.map do |arg|
    arg.respond_to?(:description) ? arg.description : arg.inspect
  end.join(", ")
end

def args_and_options(args)

def args_and_options(args)
  opts = {:xml => false, :strict => false}
  if args.last.is_a?(::Hash)
    opts[:strict] = args.last.delete(:strict) unless args.last[:strict].nil?
    opts[:xml]    = args.last.delete(:xml)    unless args.last[:xml].nil?
    args.pop if args.last.empty?
  end
  return [args, opts]
end

def description

def description
  {
    :assert_select => "have tag#{format_args(*@args)}",
    :assert_select_email => "send email#{format_args(*@args)}",
  }[@selector_assertion]
end

def doc_from(response_or_text)

def doc_from(response_or_text)
  response_or_text.extend TestResponseOrString
  if response_or_text.test_response?
    HTML::Document.new(response_or_text.body, @options[:strict], @options[:xml]).root
  elsif response_or_text.string?
    HTML::Document.new(response_or_text, @options[:strict], @options[:xml]).root
   end
end

def failure_message_for_should; @error.message; end

def failure_message_for_should; @error.message; end

def failure_message_for_should_not; "should not #{description}, but did"; end

def failure_message_for_should_not; "should not #{description}, but did"; end

def format_args(*args)

def format_args(*args)
  args.empty? ? "" : "(#{arg_list(*args)})"
end

def initialize(selector_assertion, spec_scope, *args, &block)

def initialize(selector_assertion, spec_scope, *args, &block)
  @args, @options = args_and_options(args)
  @spec_scope = spec_scope
  @selector_assertion = selector_assertion
  @block = block
end

def matches?(response_or_text, &block)

def matches?(response_or_text, &block)
  @block = block if block
  if doc = doc_from(response_or_text)
    @args.unshift(doc)
  end
  begin
    @spec_scope.__send__(@selector_assertion, *@args, &@block)
    true
  rescue ::Test::Unit::AssertionFailedError => @error
    false
  end
end