Class: Spec::Watir::HaveHtml

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/ui/watir_helper.rb

Overview

:nodoc

Instance Method Summary collapse

Constructor Details

#initialize(text_or_regexp) ⇒ HaveHtml

Returns a new instance of HaveHtml.



79
80
81
# File 'lib/spec/ui/watir_helper.rb', line 79

def initialize(text_or_regexp)
  @text_or_regexp = text_or_regexp
end

Instance Method Details

#failure_messageObject



92
93
94
# File 'lib/spec/ui/watir_helper.rb', line 92

def failure_message
  "Expected browser to have HTML matching #{@text_or_regexp}, but it was not found in:\n#{@browser.html}"
end

#matches?(browser) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
90
# File 'lib/spec/ui/watir_helper.rb', line 83

def matches?(browser)
  @browser = browser
  if @text_or_regexp.is_a?(Regexp)
    !!browser.html =~ @text_or_regexp
  else
    !!browser.html.index(@text_or_regexp.to_s)
  end
end

#negative_failure_messageObject



96
97
98
# File 'lib/spec/ui/watir_helper.rb', line 96

def negative_failure_message
  "Expected browser to not have HTML matching #{@text_or_regexp}, but it was found in:\n#{@browser.html}"
end