Class: Spec::Rails::Matchers::AssertSelect
- Inherits:
-
Object
- Object
- Spec::Rails::Matchers::AssertSelect
- Defined in:
- lib/spec/rails/matchers/assert_select.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(assertion, spec_scope, *args, &block) ⇒ AssertSelect
constructor
A new instance of AssertSelect.
- #matches?(response_or_text, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(assertion, spec_scope, *args, &block) ⇒ AssertSelect
Returns a new instance of AssertSelect.
9 10 11 12 13 14 |
# File 'lib/spec/rails/matchers/assert_select.rb', line 9 def initialize(assertion, spec_scope, *args, &block) @assertion = assertion @spec_scope = spec_scope @args = args @block = block end |
Instance Method Details
#description ⇒ Object
37 38 39 40 41 42 |
# File 'lib/spec/rails/matchers/assert_select.rb', line 37 def description { :assert_select => "have tag#{format_args(*@args)}", :assert_select_email => "send email#{format_args(*@args)}", }[@assertion] end |
#failure_message ⇒ Object
34 |
# File 'lib/spec/rails/matchers/assert_select.rb', line 34 def ; @error.; end |
#matches?(response_or_text, &block) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spec/rails/matchers/assert_select.rb', line 16 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 |
#negative_failure_message ⇒ Object
35 |
# File 'lib/spec/rails/matchers/assert_select.rb', line 35 def ; "should not #{description}, but did"; end |