Class: ContainsText
- Inherits:
-
Object
- Object
- ContainsText
- Defined in:
- lib/rwebunit/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/rwebunit/matchers/contains_text.rb', line 7 def initialize(expected) @expected = expected end |
Instance Method Details
#actual_text ⇒ Object
16 17 18 |
# File 'lib/rwebunit/matchers/contains_text.rb', line 16 def actual_text @actual.to_s.length > 1000000 ? @actual[0, 1000] : @actual end |
#failure_message ⇒ Object
error message for should
21 22 23 |
# File 'lib/rwebunit/matchers/contains_text.rb', line 21 def "expected #{actual_text} not to contains #{@expected}, but it did't" end |
#matches?(actual) ⇒ Boolean
11 12 13 14 |
# File 'lib/rwebunit/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/rwebunit/matchers/contains_text.rb', line 26 def "expected #{actual_text} not to contains #{@expected}, but it did" end |