Class: Dekiru::Capybara::Matchers::JsNoErrorMatcher
- Inherits:
-
Object
- Object
- Dekiru::Capybara::Matchers::JsNoErrorMatcher
- Defined in:
- lib/dekiru/capybara/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(example_description) ⇒ JsNoErrorMatcher
constructor
A new instance of JsNoErrorMatcher.
- #matches?(page_or_logs) ⇒ Boolean
Constructor Details
#initialize(example_description) ⇒ JsNoErrorMatcher
Returns a new instance of JsNoErrorMatcher.
5 6 7 |
# File 'lib/dekiru/capybara/matchers.rb', line 5 def initialize(example_description) @example_description = example_description end |
Instance Method Details
#description ⇒ Object
24 25 26 |
# File 'lib/dekiru/capybara/matchers.rb', line 24 def description 'have no js errors' end |
#failure_message ⇒ Object
28 29 30 |
# File 'lib/dekiru/capybara/matchers.rb', line 28 def @severe_errors.map(&:message).join("\n") end |
#matches?(page_or_logs) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dekiru/capybara/matchers.rb', line 9 def matches?(page_or_logs) logs = if page_or_logs.respond_to?(:driver) page_or_logs.driver.browser.logs.get(:browser) else page_or_logs end logs.find_all { |log| log.level == 'WARNING' }.each do |log| STDERR.puts "WARN: javascript warning in #{@example_description}" STDERR.puts log. end @severe_errors = logs.find_all { |log| log.level == 'SEVERE' } @severe_errors.empty? end |