Skip to content

Commit d98fc13

Browse files
committed
Fix rubocop
1 parent 7f4c5bf commit d98fc13

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

lib/ferrum/browser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initialize(options = nil)
6767

6868
self.base_url = @options[:base_url] if @options.key?(:base_url)
6969

70-
if ENV["FERRUM_DEBUG"] && !@logger
70+
if ENV.fetch("FERRUM_DEBUG", nil) && !@logger
7171
$stdout.sync = true
7272
@logger = $stdout
7373
@options[:logger] = @logger

lib/ferrum/browser/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(defaults, options, user_data_dir)
2929
@defaults = defaults
3030
@options = options
3131
@user_data_dir = user_data_dir
32-
@path = options[:browser_path] || ENV["BROWSER_PATH"] || defaults.detect_path
32+
@path = options[:browser_path] || ENV.fetch("BROWSER_PATH", nil) || defaults.detect_path
3333
raise Cliver::Dependency::NotFound, NOT_FOUND unless @path
3434

3535
merge_options

lib/ferrum/network.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ def build_exchange(id)
151151
Network::Exchange.new(@page, id).tap { |e| @traffic << e }
152152
end
153153

154-
def emulate_network_conditions(offline: false, latency: 0, download_throughput: -1, upload_throughput: -1, connection_type: nil)
154+
def emulate_network_conditions(offline: false, latency: 0,
155+
download_throughput: -1, upload_throughput: -1,
156+
connection_type: nil)
155157
params = {
156158
offline: offline, latency: latency,
157159
downloadThroughput: download_throughput,
158160
uploadThroughput: upload_throughput
159161
}
160162

161-
if connection_type && ALLOWED_CONNECTION_TYPE.include?(connection_type)
162-
params[:connectionType] = connection_type
163-
end
163+
params[:connectionType] = connection_type if connection_type && ALLOWED_CONNECTION_TYPE.include?(connection_type)
164164

165165
@page.command("Network.emulateNetworkConditions", params)
166166
true

spec/browser_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ module Ferrum
369369
it "allows the driver to have a custom host", skip: ENV["BROWSER_TEST_HOST"].nil? do
370370
# Use custom host "pointing" to localhost in /etc/hosts or iptables for this.
371371
# https://superuser.com/questions/516208/how-to-change-ip-address-to-point-to-localhost
372-
browser = Browser.new(host: ENV["BROWSER_TEST_HOST"], port: 12_345)
372+
browser = Browser.new(host: ENV.fetch("BROWSER_TEST_HOST"), port: 12_345)
373373
browser.go_to(base_url)
374374

375375
expect do
376-
TCPServer.new(ENV["BROWSER_TEST_HOST"], 12_345)
376+
TCPServer.new(ENV.fetch("BROWSER_TEST_HOST"), 12_345)
377377
end.to raise_error(Errno::EADDRINUSE)
378378
ensure
379379
browser&.quit

spec/network_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ module Ferrum
407407
page.network.offline_mode
408408

409409
expect { page.go_to("/ferrum/with_js") }.to raise_error(
410-
Ferrum::StatusError,
411-
%r{Request to http://.*/ferrum/with_js failed to reach server, check DNS and server status}
412-
)
410+
Ferrum::StatusError,
411+
%r{Request to http://.*/ferrum/with_js failed to reach server, check DNS and server status}
412+
)
413413

414414
expect(page.body).to eq("<html><head></head><body></body></html>")
415415
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
end
5555

5656
config.after(:each) do |example|
57-
save_exception_artifacts(browser, example.metadata, ferrum_logger) if ENV["CI"] && example.exception
57+
save_exception_artifacts(browser, example.metadata, ferrum_logger) if ENV.fetch("CI", nil) && example.exception
5858

5959
reset
6060
end

0 commit comments

Comments
 (0)