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