Class: ContainsText
- Inherits:
-
Object
- Object
- ContainsText
- Defined in:
- lib/rwebspec-webdriver/matchers/contains_text.rb
Instance Method Summary collapse
- #actual_text ⇒ Object
-
#failure_message ⇒ Object
error message for should.
-
#initialize(expected) ⇒ ContainsText
constructor
this is what the matcher is called on.
- #matches?(actual) ⇒ Boolean
-
#negative_failure_message ⇒ Object
error message for should_not.
Constructor Details
#initialize(expected) ⇒ ContainsText
this is what the matcher is called on. In this case:
foo.should contains(:bars)
foo would be passed to the initialize
7 8 9 |
# File 'lib/rwebspec-webdriver/matchers/contains_text.rb', line 7 def initialize(expected) @expected = expected end |
Instance Method Details
#actual_text ⇒ Object
16 17 18 |
# File 'lib/rwebspec-webdriver/matchers/contains_text.rb', line 16 def actual_text @actual.to_s.length > 256 ? @actual[0, 255] : @actual end |
#failure_message ⇒ Object
error message for should
21 22 23 |
# File 'lib/rwebspec-webdriver/matchers/contains_text.rb', line 21 def "expected '#{actual_text}' to contain '#{@expected}', but it didn't" end |
#matches?(actual) ⇒ Boolean
11 12 13 14 |
# File 'lib/rwebspec-webdriver/matchers/contains_text.rb', line 11 def matches?(actual) @actual = actual return actual && actual.include?(@expected) end |
#negative_failure_message ⇒ Object
error message for should_not
26 27 28 |
# File 'lib/rwebspec-webdriver/matchers/contains_text.rb', line 26 def "expected '#{actual_text}' not to contain '#{@expected}', but it did" end |