class Spec::Rails::Matchers::AssertSelect

:nodoc:

def arg_list(*args)

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

def description

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

def failure_message; @error.message; end

def failure_message; @error.message; end

def format_args(*args)

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

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

def initialize(assertion, spec_scope, *args, &block)
  @assertion = assertion
  @spec_scope = spec_scope
  @args = args
  @block = block
end

def matches?(response_or_text, &block)

def matches?(response_or_text, &block)
  if ActionController::TestResponse === response_or_text and
           response_or_text.headers.key?('Content-Type') and
           !response_or_text.headers['Content-Type'].blank? and
           response_or_text.headers['Content-Type'].to_sym == :xml
    @args.unshift(HTML::Document.new(response_or_text.body, false, true).root)           
  elsif String === response_or_text
    @args.unshift(HTML::Document.new(response_or_text).root)
  end
  @block = block if block
  begin
    @spec_scope.send(@assertion, *@args, &@block)
  rescue ::Test::Unit::AssertionFailedError => @error
  end
  
  @error.nil?
end

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

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