Skip to content

Commit bafb63d

Browse files
committed
[rb] fix rubocop rspec issues
1 parent 5ce5555 commit bafb63d

File tree

85 files changed

+1217
-1163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1217
-1163
lines changed

rb/spec/integration/selenium/webdriver/action_builder_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ module WebDriver
310310
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
311311
iframe = driver.find_element(tag_name: 'iframe')
312312

313-
expect(in_viewport?(iframe)).to eq false
313+
expect(in_viewport?(iframe)).to be false
314314

315315
driver.action.scroll_to(iframe).perform
316316

317-
expect(in_viewport?(iframe)).to eq true
317+
expect(in_viewport?(iframe)).to be true
318318
end
319319
end
320320

@@ -330,7 +330,7 @@ module WebDriver
330330
driver.action.scroll_by(0, delta_y).perform
331331
sleep 0.5
332332

333-
expect(in_viewport?(footer)).to eq true
333+
expect(in_viewport?(footer)).to be true
334334
end
335335
end
336336

@@ -346,7 +346,7 @@ module WebDriver
346346
driver.switch_to.frame(iframe)
347347
sleep 0.5
348348
checkbox = driver.find_element(name: 'scroll_checkbox')
349-
expect(in_viewport?(checkbox)).to eq true
349+
expect(in_viewport?(checkbox)).to be true
350350
end
351351

352352
it 'scrolls from element by given amount with offset',
@@ -361,7 +361,7 @@ module WebDriver
361361
iframe = driver.find_element(tag_name: 'iframe')
362362
driver.switch_to.frame(iframe)
363363
checkbox = driver.find_element(name: 'scroll_checkbox')
364-
expect(in_viewport?(checkbox)).to eq true
364+
expect(in_viewport?(checkbox)).to be true
365365
end
366366

367367
it 'raises MoveTargetOutOfBoundsError when origin offset from element is out of viewport' do
@@ -384,7 +384,7 @@ module WebDriver
384384
driver.switch_to.frame(iframe)
385385
checkbox = driver.find_element(name: 'scroll_checkbox')
386386
sleep 0.5
387-
expect(in_viewport?(checkbox)).to eq true
387+
expect(in_viewport?(checkbox)).to be true
388388
end
389389

390390
it 'raises MoveTargetOutOfBoundsError when origin offset is out of viewport' do

rb/spec/integration/selenium/webdriver/bidi/browsing_context_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,33 @@ class BiDi
2828

2929
it 'can create a browsing context for given id' do
3030
id = driver.window_handle
31-
browsing_context = BrowsingContext.new(driver: driver, browsing_context_id: id)
31+
browsing_context = described_class.new(driver: driver, browsing_context_id: id)
3232
expect(browsing_context.id).to eq(id)
3333
end
3434

3535
it 'can create a window' do
36-
browsing_context = BrowsingContext.new(driver: driver, type: :window)
36+
browsing_context = described_class.new(driver: driver, type: :window)
3737
expect(browsing_context.id).not_to be_nil
3838
end
3939

4040
it 'can create a window with a reference context' do
41-
browsing_context = BrowsingContext.new(driver: driver, type: :window,
41+
browsing_context = described_class.new(driver: driver, type: :window,
4242
reference_context: driver.window_handle)
4343
expect(browsing_context.id).not_to be_nil
4444
end
4545

4646
it 'can create a tab' do
47-
browsing_context = BrowsingContext.new(driver: driver, type: :tab)
47+
browsing_context = described_class.new(driver: driver, type: :tab)
4848
expect(browsing_context.id).not_to be_nil
4949
end
5050

5151
it 'can create a tab with a reference context' do
52-
browsing_context = BrowsingContext.new(driver: driver, type: :tab, reference_context: driver.window_handle)
52+
browsing_context = described_class.new(driver: driver, type: :tab, reference_context: driver.window_handle)
5353
expect(browsing_context.id).not_to be_nil
5454
end
5555

5656
it 'can navigate to a url' do
57-
browsing_context = BrowsingContext.new(driver: driver, type: :tab)
57+
browsing_context = described_class.new(driver: driver, type: :tab)
5858

5959
info = browsing_context.navigate url: url_for('/bidi/logEntryAdded.html')
6060

@@ -64,7 +64,7 @@ class BiDi
6464
end
6565

6666
it 'can navigate to a url with readiness state' do
67-
browsing_context = BrowsingContext.new(driver: driver, type: :tab)
67+
browsing_context = described_class.new(driver: driver, type: :tab)
6868

6969
info = browsing_context.navigate url: url_for('/bidi/logEntryAdded.html'),
7070
readiness_state: :complete
@@ -76,7 +76,7 @@ class BiDi
7676

7777
it 'can get tree with a child' do
7878
browsing_context_id = driver.window_handle
79-
parent_window = BrowsingContext.new(driver: driver, browsing_context_id: browsing_context_id)
79+
parent_window = described_class.new(driver: driver, browsing_context_id: browsing_context_id)
8080
parent_window.navigate(url: url_for('iframes.html'),
8181
readiness_state: :complete)
8282

@@ -88,7 +88,7 @@ class BiDi
8888

8989
it 'can get tree with depth' do
9090
browsing_context_id = driver.window_handle
91-
parent_window = BrowsingContext.new(driver: driver, browsing_context_id: browsing_context_id)
91+
parent_window = described_class.new(driver: driver, browsing_context_id: browsing_context_id)
9292
parent_window.navigate(url: url_for('iframes.html'),
9393
readiness_state: :complete)
9494

@@ -98,8 +98,8 @@ class BiDi
9898
end
9999

100100
it 'can close a window' do
101-
window1 = BrowsingContext.new(driver: driver, type: :window)
102-
window2 = BrowsingContext.new(driver: driver, type: :window)
101+
window1 = described_class.new(driver: driver, type: :window)
102+
window2 = described_class.new(driver: driver, type: :window)
103103

104104
window2.close
105105

rb/spec/integration/selenium/webdriver/bidi/log_inspector_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BiDi
3030
it 'can listen to console log' do
3131
reset_driver!(web_socket_url: true) do |driver|
3232
log_entry = nil
33-
log_inspector = LogInspector.new(driver)
33+
log_inspector = described_class.new(driver)
3434
log_inspector.on_console_entry { |log| log_entry = log }
3535

3636
driver.navigate.to url_for(@page)
@@ -52,7 +52,7 @@ class BiDi
5252
it 'can listen to javascript log' do
5353
reset_driver!(web_socket_url: true) do |driver|
5454
log_entry = nil
55-
log_inspector = LogInspector.new(driver)
55+
log_inspector = described_class.new(driver)
5656
log_inspector.on_javascript_log { |log| log_entry = log }
5757

5858
driver.navigate.to url_for(@page)
@@ -70,7 +70,7 @@ class BiDi
7070
it 'can listen to javascript error log' do
7171
reset_driver!(web_socket_url: true) do |driver|
7272
log_entry = nil
73-
log_inspector = LogInspector.new(driver)
73+
log_inspector = described_class.new(driver)
7474
log_inspector.on_javascript_exception { |log| log_entry = log }
7575

7676
driver.navigate.to url_for(@page)
@@ -88,7 +88,7 @@ class BiDi
8888
it 'can listen to any log' do
8989
reset_driver!(web_socket_url: true) do |driver|
9090
log_entry = nil
91-
log_inspector = LogInspector.new(driver)
91+
log_inspector = described_class.new(driver)
9292
log_inspector.on_log { |log| log_entry = log }
9393

9494
driver.navigate.to url_for(@page)
@@ -104,7 +104,7 @@ class BiDi
104104
it 'can retrieve stack trace for a log' do
105105
reset_driver!(web_socket_url: true) do |driver|
106106
log_entry = nil
107-
log_inspector = LogInspector.new(driver)
107+
log_inspector = described_class.new(driver)
108108
log_inspector.on_javascript_log { |log| log_entry = log }
109109

110110
driver.navigate.to url_for(@page)

rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb

+9-11
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ module Chrome
3434
end
3535

3636
it 'sets download path' do
37-
driver.download_path = File.expand_path(__dir__)
38-
# there is no simple way to verify that it's now possible to download
39-
# at least it doesn't crash
37+
expect { driver.download_path = File.expand_path(__dir__) }.not_to raise_exception
4038
end
4139

4240
it 'can execute CDP commands' do
@@ -66,19 +64,19 @@ module Chrome
6664

6765
let(:magic_number) { 'JVBER' }
6866

69-
it 'should return base64 for print command' do
67+
it 'returns base64 for print command' do
7068
driver.navigate.to url_for('printPage.html')
7169
expect(driver.print_page).to include(magic_number)
7270
end
7371

74-
it 'should print with valid params' do
72+
it 'prints with valid params' do
7573
driver.navigate.to url_for('printPage.html')
7674
expect(driver.print_page(orientation: 'landscape',
7775
page_ranges: ['1-2'],
7876
page: {width: 30})).to include(magic_number)
7977
end
8078

81-
it 'should save pdf' do
79+
it 'saves pdf' do
8280
driver.navigate.to url_for('printPage.html')
8381

8482
path = "#{Dir.tmpdir}/test#{SecureRandom.urlsafe_base64}.pdf"
@@ -112,26 +110,26 @@ module Chrome
112110

113111
entries = driver.logs.get(:browser)
114112
expect(entries).not_to be_empty
115-
expect(entries.first).to be_kind_of(LogEntry)
113+
expect(entries.first).to be_a(LogEntry)
116114
end
117115

118116
it 'can get the driver log' do
119117
entries = driver.logs.get(:driver)
120118
expect(entries).not_to be_empty
121-
expect(entries.first).to be_kind_of(LogEntry)
119+
expect(entries.first).to be_a(LogEntry)
122120
end
123121

124122
it 'can get the performance log' do
125123
entries = driver.logs.get(:performance)
126124
expect(entries).not_to be_empty
127-
expect(entries.first).to be_kind_of(LogEntry)
125+
expect(entries.first).to be_a(LogEntry)
128126
end
129127
end
130128

131129
it 'manages network features' do
132130
driver.network_conditions = {offline: false, latency: 56, download_throughput: 789, upload_throughput: 600}
133131
conditions = driver.network_conditions
134-
expect(conditions['offline']).to eq false
132+
expect(conditions['offline']).to be false
135133
expect(conditions['latency']).to eq 56
136134
expect(conditions['download_throughput']).to eq 789
137135
expect(conditions['upload_throughput']).to eq 600
@@ -150,7 +148,7 @@ module Chrome
150148
unless sinks.empty?
151149
device_name = sinks.first['name']
152150
driver.start_cast_tab_mirroring(device_name)
153-
driver.stop_casting(device_name)
151+
expect { driver.stop_casting(device_name) }.not_to raise_exception
154152
end
155153
end
156154

rb/spec/integration/selenium/webdriver/chrome/profile_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Selenium
2323
module WebDriver
2424
module Chrome
2525
describe Profile, exclusive: {browser: :chrome} do
26-
let(:profile) { Profile.new }
26+
let(:profile) { described_class.new }
2727

2828
it 'adds an extension' do
2929
ext_path = '/some/path.crx'

rb/spec/integration/selenium/webdriver/chrome/service_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Selenium
2323
module WebDriver
2424
module Chrome
2525
describe Service, exclusive: {browser: :chrome} do
26-
let(:service) { Service.new }
26+
let(:service) { described_class.new }
2727
let(:service_manager) { service.launch }
2828

2929
after { service_manager.stop }

rb/spec/integration/selenium/webdriver/devtools_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ module WebDriver
4747
}.to raise_error(RuntimeError, "This is fine!")
4848
end
4949

50-
context 'authentication', except: {browser: :firefox,
51-
reason: 'Fetch.enable is not yet supported'} do
50+
describe '#register', except: {browser: :firefox,
51+
reason: 'Fetch.enable is not yet supported'} do
5252
let(:username) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.first }
5353
let(:password) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.last }
5454

@@ -152,8 +152,8 @@ module WebDriver
152152
expect(mutation.old_value).to eq('display:none;')
153153
end
154154

155-
context 'network interception', except: {browser: :firefox,
156-
reason: 'Fetch.enable is not yet supported'} do
155+
describe '#intercept', except: {browser: :firefox,
156+
reason: 'Fetch.enable is not yet supported'} do
157157
it 'continues requests' do
158158
requests = []
159159
driver.intercept do |request, &continue|
@@ -202,7 +202,7 @@ module WebDriver
202202
end
203203
end
204204

205-
context 'script pinning', except: {browser: :firefox} do
205+
describe '#pin_script', except: {browser: :firefox} do
206206
before do
207207
driver.navigate.to url_for('xhtmlTest.html')
208208
end

0 commit comments

Comments
 (0)