Class: Spec::Matchers::Watir::ContentMatcher
- Inherits:
-
Object
- Object
- Spec::Matchers::Watir::ContentMatcher
- Defined in:
- lib/spec/ui/watir/matchers.rb
Overview
:nodoc
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(kind, text_or_regexp) ⇒ ContentMatcher
constructor
A new instance of ContentMatcher.
- #matches?(container) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(kind, text_or_regexp) ⇒ ContentMatcher
Returns a new instance of ContentMatcher.
4 5 6 |
# File 'lib/spec/ui/watir/matchers.rb', line 4 def initialize(kind, text_or_regexp) @kind, @text_or_regexp = kind, text_or_regexp end |
Instance Method Details
#failure_message ⇒ Object
18 19 20 |
# File 'lib/spec/ui/watir/matchers.rb', line 18 def "Expected #{@container.class} to have #{@kind} matching #{@text_or_regexp}, but it was not found in:\n#{@content}" end |
#matches?(container) ⇒ Boolean
8 9 10 11 12 13 14 15 16 |
# File 'lib/spec/ui/watir/matchers.rb', line 8 def matches?(container) @container = container @content = container.__send__(@kind) if @text_or_regexp.is_a?(Regexp) !!@content =~ @text_or_regexp else !!@content.index(@text_or_regexp.to_s) end end |
#negative_failure_message ⇒ Object
22 23 24 |
# File 'lib/spec/ui/watir/matchers.rb', line 22 def "Expected #{@container.class} to not have #{@kind} matching #{@text_or_regexp}, but it was found in:\n#{@content}" end |