diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f06fdd..011b256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.3.0 + +* Prevent errors from being raised if they match a filter + # 0.2.1 [June 23, 2018] * Added `filter_levels` option for filtering by log level (closes #4) diff --git a/Gemfile.lock b/Gemfile.lock index be5c6b4..cfcf84f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,23 @@ PATH remote: . specs: - capybara-chromedriver-logger (0.2.1) + capybara-chromedriver-logger (0.3.0) capybara colorize GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - capybara (2.18.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + capybara (3.31.0) addressable mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) childprocess (0.8.0) ffi (~> 1.0, >= 1.0.11) coderay (1.1.2) @@ -25,18 +26,19 @@ GEM ffi (1.12.2) gem-release (2.0.1) method_source (0.9.0) - mini_mime (1.0.0) + mini_mime (1.0.2) mini_portile2 (2.4.0) nokogiri (1.10.8) mini_portile2 (~> 2.4.0) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) - public_suffix (3.0.2) + public_suffix (4.0.3) rack (2.0.8) - rack-test (1.0.0) + rack-test (1.1.0) rack (>= 1.0, < 3) rake (13.0.1) + regexp_parser (1.7.0) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) @@ -60,7 +62,7 @@ GEM nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0) - xpath (3.0.0) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS diff --git a/lib/capybara/chromedriver/logger/collector.rb b/lib/capybara/chromedriver/logger/collector.rb index 658ab94..bdfe8a5 100644 --- a/lib/capybara/chromedriver/logger/collector.rb +++ b/lib/capybara/chromedriver/logger/collector.rb @@ -32,9 +32,12 @@ def raise_errors_if_needed! def flush_logs! browser_logs.each do |log| message = Message.new(log) - errors << message if message.error? + + next if should_filter?(message) - log_destination.puts message.to_s unless should_filter?(message) + errors << message if message.error? + + log_destination.puts message.to_s end end diff --git a/lib/capybara/chromedriver/logger/version.rb b/lib/capybara/chromedriver/logger/version.rb index 26005e5..eb35108 100644 --- a/lib/capybara/chromedriver/logger/version.rb +++ b/lib/capybara/chromedriver/logger/version.rb @@ -1,7 +1,7 @@ module Capybara module Chromedriver module Logger - VERSION = "0.2.1" + VERSION = "0.3.0" end end end diff --git a/spec/capybara/chromedriver/logger/collector_spec.rb b/spec/capybara/chromedriver/logger/collector_spec.rb index a9a1a69..4e4118f 100644 --- a/spec/capybara/chromedriver/logger/collector_spec.rb +++ b/spec/capybara/chromedriver/logger/collector_spec.rb @@ -67,6 +67,16 @@ Capybara::Chromedriver::Logger.filter_levels = nil end + it "should ignore filtered messages" do + Capybara::Chromedriver::Logger.raise_js_errors = true + Capybara::Chromedriver::Logger.filters = [/A console error/i] + visit "/severe" + + expect_to_have_inserted_element + logger.flush_and_check_errors! + expect_no_log_messages + end + def expect_no_log_messages expect(log_destination.string).to eq('') end