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 Method Summary
collapse
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
34
35
36
37
38
39
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 34
def description
{
:assert_select => "have tag#{format_args(*@args)}",
:assert_select_email => "send email#{format_args(*@args)}",
}[@assertion]
end
|
#failure_message_for_should ⇒ Object
31
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 31
def failure_message_for_should; @error.message; end
|
#failure_message_for_should_not ⇒ Object
32
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 32
def failure_message_for_should_not; "should not #{description}, but did"; end
|
#matches?(response_or_text, &block) ⇒ Boolean
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/spec/rails/matchers/assert_select.rb', line 16
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
|