Skip to content

Commit e9d7c0c

Browse files
committed
[rb] add linting test
1 parent ce525ba commit e9d7c0c

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

.github/workflows/ruby-examples.yml

+17
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,20 @@ jobs:
110110
new_command_on_retry: |
111111
cd examples/ruby
112112
DEBUG=true bundle exec rspec --only-failures --backtrace
113+
114+
lint:
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Checkout GitHub repo
118+
uses: actions/checkout@v4
119+
- name: Set up Ruby
120+
uses: ruby/setup-ruby@v1
121+
with:
122+
ruby-version: 3.1
123+
bundler-cache: true
124+
- name: Install dependencies
125+
working-directory: ./examples/ruby
126+
run: bundle install
127+
- name: Run RuboCop
128+
working-directory: ./examples/ruby
129+
run: bundle exec rubocop

examples/ruby/.rubocop.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
inherit_from: .rubocop_todo.yml
22

3-
require: rubocop-rspec
3+
plugins:
4+
- rubocop-rspec
45

56
AllCops:
6-
TargetRubyVersion: 3.0
7+
TargetRubyVersion: 3.1
78
NewCops: enable
89
SuggestExtensions:
910
rubocop-rake: false

examples/ruby/spec/elements/finders_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212

1313
it 'uses a subset of the dom to find an element' do
1414
fruits = driver.find_element(id: 'fruits')
15-
fruit = fruits.find_element(class: 'tomatoes')
15+
fruits.find_element(class: 'tomatoes')
1616
end
1717

1818
it 'uses an optimized locator' do
19-
fruit = driver.find_element(css: '#fruits .tomatoes')
19+
driver.find_element(css: '#fruits .tomatoes')
2020
end
2121

2222
it 'finds all matching elements' do
23-
plants = driver.find_elements(tag_name: 'li')
23+
driver.find_elements(tag_name: 'li')
2424
end
2525

2626
it 'gets an element from a collection' do
27-
elements = driver.find_elements(:tag_name,'p')
27+
elements = driver.find_elements(:tag_name, 'p')
2828
elements.each { |e| puts e.text }
2929
end
3030

3131
it 'finds element from element' do
32-
element = driver.find_element(:tag_name,'div')
33-
elements = element.find_elements(:tag_name,'p')
32+
element = driver.find_element(:tag_name, 'div')
33+
elements = element.find_elements(:tag_name, 'p')
3434
elements.each { |e| puts e.text }
3535
end
3636

3737
it 'find active element' do
3838
driver.find_element(css: '[name="q"]').send_keys('webElement')
39-
attr = driver.switch_to.active_element.attribute('title')
39+
driver.switch_to.active_element.attribute('title')
4040
end
4141
end
4242
end

examples/ruby/spec/getting_started/using_selenium_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
2+
23
require 'spec_helper'
34
require 'selenium-webdriver'
45

5-
66
RSpec.describe 'Using Selenium' do
77
before do
88
@driver = Selenium::WebDriver.for :chrome

examples/ruby/spec/spec_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
# Disable RSpec exposing methods globally on `Module` and `main`
1111
config.disable_monkey_patching!
1212
Dir.mktmpdir('tmp')
13-
config.example_status_persistence_file_path = "tmp/examples.txt"
13+
config.example_status_persistence_file_path = 'tmp/examples.txt'
1414

1515
config.expect_with :rspec do |c|
1616
c.syntax = :expect
1717
end
1818

1919
config.before do |example|
20-
bug_tracker = 'https://gigithub.com/SeleniumHQ/seleniumhq.github.io/issues'
20+
bug_tracker = 'https://github.com/SeleniumHQ/seleniumhq.github.io/issues'
2121
guards = Selenium::WebDriver::Support::Guards.new(example,
2222
bug_tracker: bug_tracker)
2323
guards.add_condition(:platform, Selenium::WebDriver::Platform.os)

0 commit comments

Comments
 (0)