Class: Merb::Test::Rspec::ViewMatchers::HasContent
- Defined in:
- lib/merb-core/test/matchers/view_matchers.rb
Instance Method Summary collapse
- #content_message ⇒ Object
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#initialize(content) ⇒ HasContent
constructor
A new instance of HasContent.
- #matches?(element) ⇒ Boolean
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
Constructor Details
#initialize(content) ⇒ HasContent
Returns a new instance of HasContent.
152 153 154 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 152 def initialize(content) @content = content end |
Instance Method Details
#content_message ⇒ Object
180 181 182 183 184 185 186 187 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 180 def case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end |
#failure_message ⇒ Object
Returns
- String
-
The failure message.
170 171 172 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 170 def "expected the following element's content to #{}:\n#{@element.inner_text}" end |
#matches?(element) ⇒ Boolean
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 156 def matches?(element) element = element.body.to_s if element.respond_to?(:body) @element = element case @content when String @element.contains?(@content) when Regexp @element.matches?(@content) end end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
176 177 178 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 176 def "expected the following element's content to not #{}:\n#{@element.inner_text}" end |