Skip to content

Commit

Permalink
Merge pull request #21 from dbalatero/do-not-raise-on-filtered-errors
Browse files Browse the repository at this point in the history
Prevent errors from being raised if they match a filter
  • Loading branch information
dbalatero authored Mar 21, 2020
2 parents 026bb7d + 708932c commit ab56da1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/capybara/chromedriver/logger/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/chromedriver/logger/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Capybara
module Chromedriver
module Logger
VERSION = "0.2.1"
VERSION = "0.3.0"
end
end
end
10 changes: 10 additions & 0 deletions spec/capybara/chromedriver/logger/collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab56da1

Please sign in to comment.