Class: Spec::Rails::Matchers::AssertSelect
- Inherits:
-
Object
- Object
- Spec::Rails::Matchers::AssertSelect
show all
- Defined in:
- lib/spec/rails/matchers/assert_select.rb
Overview
Defined Under Namespace
Modules: TestResponseOrString
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(selector_assertion, spec_scope, *args, &block) ⇒ 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_and_options(args)
@spec_scope = spec_scope
@selector_assertion = selector_assertion
@block = block
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8
9
10
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 8
def options
@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 failure_message_for_should; @error.message; end
|
#failure_message_for_should_not ⇒ Object
33
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 33
def failure_message_for_should_not; "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
|