Class: Webrat::Matchers::HasContent
- Inherits:
-
Object
- Object
- Webrat::Matchers::HasContent
- Defined in:
- lib/webrat/core/matchers/have_content.rb
Overview
:nodoc:
Instance Method Summary (collapse)
- - (Object) content_message
-
- (Object) failure_message
Returns
String
The failure message.
-
- (HasContent) initialize(content)
constructor
A new instance of HasContent.
- - (Boolean) matches?(stringlike)
-
- (Object) negative_failure_message
Returns
String
The failure message to be displayed in negative matches.
- - (Object) squeeze_space(inner_text)
Constructor Details
- (HasContent) initialize(content)
A new instance of HasContent
5 6 7 |
# File 'lib/webrat/core/matchers/have_content.rb', line 5 def initialize(content) @content = content end |
Instance Method Details
- (Object) content_message
37 38 39 40 41 42 43 44 |
# File 'lib/webrat/core/matchers/have_content.rb', line 37 def case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end |
- (Object) failure_message
Returns
String |
The failure message. |
23 24 25 |
# File 'lib/webrat/core/matchers/have_content.rb', line 23 def "expected the following element's content to #{}:\n#{squeeze_space(@element)}" end |
- (Boolean) matches?(stringlike)
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/webrat/core/matchers/have_content.rb', line 9 def matches?(stringlike) @document = Webrat::XML.document(stringlike) @element = @document.inner_text case @content when String @element.gsub(/\s+/, ' ').include?(@content) when Regexp @element.match(@content) end end |
- (Object) negative_failure_message
Returns
String |
The failure message to be displayed in negative matches. |
29 30 31 |
# File 'lib/webrat/core/matchers/have_content.rb', line 29 def "expected the following element's content to not #{}:\n#{squeeze_space(@element)}" end |
- (Object) squeeze_space(inner_text)
33 34 35 |
# File 'lib/webrat/core/matchers/have_content.rb', line 33 def squeeze_space(inner_text) inner_text.gsub(/^\s*$/, "").squeeze("\n") end |