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 description
def description { :assert_select => "have tag#{format_args(*@args)}", :assert_select_email => "send email#{format_args(*@args)}", }[@assertion] end
def doc_from(response_or_text)
def doc_from(response_or_text) response_or_text.extend TestResponseOrString markup = response_or_text.body if response_or_text.test_response? markup = response_or_text if response_or_text.string? HTML::Document.new(markup, false, true).root if markup 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(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) @block = block if block if doc = doc_from(response_or_text) @args.unshift(doc) end begin @spec_scope.__send__(@assertion, *@args, &@block) true rescue ::Test::Unit::AssertionFailedError => @error false end end