Skip to content

Commit 61d4654

Browse files
committed
[rb] fix linter issues with action classes
1 parent a47dade commit 61d4654

9 files changed

Lines changed: 50 additions & 44 deletions

File tree

rb/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module PointerEventProperties
2929
tilt_y: {'tiltY' => {min: -90, max: 90}},
3030
twist: {'twist' => {min: 0, max: 359}},
3131
altitude_angle: {'altitudeAngle' => {min: 0.0, max: (Math::PI / 2)}},
32-
azimuth_angle: {'azimuthAngle' => {min: 0.0, max: (Math::PI * 2)}}}
32+
azimuth_angle: {'azimuthAngle' => {min: 0.0, max: (Math::PI * 2)}}}.freeze
3333

3434
def process_opts
3535
raise ArgumentError, "Unknown options found: #{@opts.inspect}" unless (@opts.keys - VALID.keys).empty?

rb/lib/selenium/webdriver/common/interactions/scroll.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Scroll < Interaction
3030
VIEWPORT = :viewport
3131
POINTER = :pointer
3232

33-
def initialize(source, duration, origin, x, y, delta_x, delta_y)
33+
def initialize(source, duration, delta_x, delta_y, origin: VIEWPORT, x: 0, y: 0)
3434
super(source)
3535
@type = :scroll
3636
@duration = duration * 1000

rb/lib/selenium/webdriver/common/interactions/wheel_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def initialize(name = nil)
3333
end
3434

3535
def create_scroll(duration: 0, x: 0, y: 0, delta_x: 0, delta_y: 0, origin: nil)
36-
add_action(Scroll.new(self, duration, origin, x, y, delta_x, delta_y))
36+
add_action(Scroll.new(self, duration, delta_x, delta_y, origin: origin, x: x, y: y))
3737
end
3838
end # PointerInput
3939
end # Interactions

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ module WebDriver
259259
end
260260

261261
def in_viewport?(element)
262-
in_viewport = <<-IN_VIEWPORT
263-
for(var e=arguments[0],f=e.offsetTop,t=e.offsetLeft,o=e.offsetWidth,n=e.offsetHeight;
264-
e.offsetParent;)f+=(e=e.offsetParent).offsetTop,t+=e.offsetLeft;
265-
return f<window.pageYOffset+window.innerHeight&&t<window.pageXOffset+window.innerWidth&&f+n>
266-
window.pageYOffset&&t+o>window.pageXOffset
262+
in_viewport = <<~IN_VIEWPORT
263+
for(var e=arguments[0],f=e.offsetTop,t=e.offsetLeft,o=e.offsetWidth,n=e.offsetHeight;
264+
e.offsetParent;)f+=(e=e.offsetParent).offsetTop,t+=e.offsetLeft;
265+
return f<window.pageYOffset+window.innerHeight&&t<window.pageXOffset+window.innerWidth&&f+n>
266+
window.pageYOffset&&t+o>window.pageXOffset
267267
IN_VIEWPORT
268268

269269
driver.execute_script(in_viewport, element)

rb/spec/unit/selenium/webdriver/common/interactions/pointer_event_prop_spec.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ def initialize(opts)
3131
@opts = opts
3232
end
3333

34-
def assert_source(*) ; end
34+
def assert_source(*); end
3535
end
3636
end
37-
let(:opts) { {width: 0,
38-
height: 0,
39-
pressure: 0.5,
40-
tangential_pressure: 0.4,
41-
tilt_x: -40,
42-
tilt_y: -10,
43-
twist: 177,
44-
altitude_angle: 1.0,
45-
azimuth_angle: 0.5} }
37+
let(:opts) do
38+
{width: 0,
39+
height: 0,
40+
pressure: 0.5,
41+
tangential_pressure: 0.4,
42+
tilt_x: -40,
43+
tilt_y: -10,
44+
twist: 177,
45+
altitude_angle: 1.0,
46+
azimuth_angle: 0.5}
47+
end
4648

4749
describe '#process_opts' do
4850
it 'validates all pointer event properties' do
@@ -63,7 +65,6 @@ def assert_source(*) ; end
6365
pointer.process_opts
6466
expect(pointer).to have_received(:assert_number).exactly(7).times
6567
end
66-
6768
end
6869

6970
describe '#assert_number' do

rb/spec/unit/selenium/webdriver/common/interactions/pointer_move_spec.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ module Interactions
2929
let(:duration) { 0.5 }
3030
let(:x) { 25 }
3131
let(:y) { 50 }
32-
let(:opts) { {width: 0,
33-
height: 0,
34-
pressure: 0.5,
35-
tangential_pressure: 0.4,
36-
tilt_x: -40,
37-
tilt_y: -10,
38-
twist: 177,
39-
altitude_angle: 1.0,
40-
azimuth_angle: 0.5} }
32+
let(:opts) do
33+
{width: 0,
34+
height: 0,
35+
pressure: 0.5,
36+
tangential_pressure: 0.4,
37+
tilt_x: -40,
38+
tilt_y: -10,
39+
twist: 177,
40+
altitude_angle: 1.0,
41+
azimuth_angle: 0.5}
42+
end
4143

4244
describe '#initialize' do
4345
it 'raises a TypeError if source is not a PointerInput' do

rb/spec/unit/selenium/webdriver/common/interactions/pointer_press_spec.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ module Interactions
2727
let(:direction) { :down }
2828
let(:button) { :left }
2929
let(:press) { PointerPress.new(source, direction, button) }
30-
let(:opts) { {width: 0,
31-
height: 0,
32-
pressure: 0.5,
33-
tangential_pressure: 0.4,
34-
tilt_x: -40,
35-
tilt_y: -10,
36-
twist: 177,
37-
altitude_angle: 1.0,
38-
azimuth_angle: 0.5} }
30+
let(:opts) do
31+
{width: 0,
32+
height: 0,
33+
pressure: 0.5,
34+
tangential_pressure: 0.4,
35+
tilt_x: -40,
36+
tilt_y: -10,
37+
twist: 177,
38+
altitude_angle: 1.0,
39+
azimuth_angle: 0.5}
40+
end
3941

4042
describe '#initialize' do
4143
it 'raises a ArgumentError if invalid button symbol' do

rb/spec/unit/selenium/webdriver/common/interactions/scroll_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ module Interactions
2929
let(:duration) { 0.5 }
3030
let(:x) { 25 }
3131
let(:y) { 50 }
32-
let(:delta_x) { 30}
32+
let(:delta_x) { 30 }
3333
let(:delta_y) { 60 }
34-
let(:scroll) { Scroll.new(source, duration, origin, x, y, delta_x, delta_y) }
34+
let(:scroll) { Scroll.new(source, duration, delta_x, delta_y, origin: origin, x: x, y: y) }
3535

3636
describe '#initialize' do
3737
it 'raises a TypeError if source is not a Wheel' do
3838
key = Interactions.key('key')
39-
expect { Scroll.new(key, duration, origin, x, y, delta_x, delta_y) }.to raise_error(TypeError)
39+
expect { Scroll.new(key, duration, delta_x, delta_y, origin: origin, x: x, y: y) }.to raise_error(TypeError)
4040
end
4141
end
4242

@@ -49,7 +49,7 @@ module Interactions
4949
describe '#encode' do
5050
context 'with element' do
5151
it 'returns a Hash with source, duration, x and y' do
52-
scroll = Scroll.new(source, duration, element, x, y, delta_x, delta_y)
52+
scroll = Scroll.new(source, duration, delta_x, delta_y, origin: element, x: x, y: y)
5353
allow(element).to receive(:is_a?).with(Element).and_return(true)
5454

5555
expect(scroll.encode).to eq('type' => 'scroll',

rb/spec/unit/selenium/webdriver/common/interactions/wheel_input_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module Interactions
2828
let(:duration) { 0.5 }
2929
let(:x) { 25 }
3030
let(:y) { 50 }
31-
let(:delta_x) { 30}
31+
let(:delta_x) { 30 }
3232
let(:delta_y) { 60 }
33-
let(:scroll) { Scroll.new(wheel, duration, origin, x, y, delta_x, delta_y) }
33+
let(:scroll) { Scroll.new(wheel, duration, delta_x, delta_y, origin: origin, x: x, y: y) }
3434

3535
describe '#type' do
3636
it 'returns :wheel' do
@@ -40,7 +40,8 @@ module Interactions
4040

4141
describe '#create_scroll' do
4242
it 'executes #add_action with created interaction' do
43-
allow(Scroll).to receive(:new).with(wheel, duration, origin, x, y, delta_x, delta_y).and_return(scroll)
43+
allow(Scroll).to receive(:new).with(wheel, duration, delta_x, delta_y, origin: origin, x: x, y: y)
44+
.and_return(scroll)
4445
allow(wheel).to receive(:add_action).and_call_original
4546

4647
wheel.create_scroll(duration: duration, x: x, y: y, delta_x: delta_x, delta_y: delta_y, origin: origin)

0 commit comments

Comments
 (0)