Skip to content

Commit 1cb36b1

Browse files
committed
Update Rubocop config, fix offenses
1 parent 1f89812 commit 1cb36b1

10 files changed

+183
-139
lines changed

.rubocop.yml

+27-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AllCops:
1212
Exclude:
1313
- bin/*
1414
- gemfiles/*
15-
- spec/**/*
15+
- spec/dummy/**/*
1616
- lib/generators/**/*.rb
1717

1818
Gemspec/RequireMFA:
@@ -94,3 +94,29 @@ Metrics/BlockLength:
9494

9595
Metrics/BlockNesting:
9696
Enabled: false
97+
98+
#########
99+
# RSPEC #
100+
#########
101+
102+
RSpec/NotToNot:
103+
EnforcedStyle: to_not
104+
105+
RSpec/ExampleLength:
106+
Max: 9
107+
108+
RSpec/MultipleExpectations:
109+
Max: 4
110+
111+
RSpec/MetadataStyle:
112+
EnforcedStyle: hash
113+
114+
############
115+
# CAPYBARA #
116+
############
117+
118+
Capybara/NegationMatcher:
119+
EnforcedStyle: not_to
120+
121+
Capybara/ClickLinkOrButtonStyle:
122+
EnforcedStyle: strict

spec/config_capybara.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
def register_driver(driver_name, args = [])
24
opts = { js_errors: true, headless: true, window_size: [1920, 1200], browser_options: {} }
35
args.each do |arg|

spec/config_rspec.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
# Configure RSpec
24
RSpec.configure do |config|
35
config.include WaitForAjax, type: :feature
46

5-
config.fixture_path = "#{::Rails.root}/fixtures"
7+
config.fixture_path = Rails.root.join('fixtures')
68
config.use_transactional_fixtures = false
79
config.infer_spec_type_from_file_location!
810

@@ -25,16 +27,16 @@
2527
DatabaseCleaner.strategy = :truncation
2628
end
2729

28-
config.before(:each) do
30+
config.before do
2931
DatabaseCleaner.start
3032
end
3133

32-
config.after(:each) do
34+
config.after do
3335
DatabaseCleaner.clean
3436
end
3537

3638
if ENV.key?('GITHUB_ACTIONS')
37-
config.around(:each) do |ex|
39+
config.around do |ex|
3840
ex.run_with_retry retry: 3
3941
end
4042
end

spec/features/custom_filters_spec.rb

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
RSpec.feature 'Combine custom filtering' do
@@ -6,65 +8,65 @@
68
scenario 'The user search user, change pagination and change page', js: true do
79
visit admin_users_path
810

9-
#page_sizes => [3, 10]
10-
within(".pagination-per-page") { click_on "10" }
11-
expect(page).to have_selector('tr.editable', count: 8)
11+
# page_sizes => [3, 10]
12+
within('.pagination-per-page') { click_link '10' }
13+
expect(page).to have_css('tr.editable', count: 8)
1214

13-
fill_in "filter", with: "test"
15+
fill_in 'filter', with: 'test'
1416
sleep 1
15-
expect(page).to have_selector('tr.editable', count: 4)
17+
expect(page).to have_css('tr.editable', count: 4)
1618

17-
within(".pagination-per-page") { click_on "3" }
18-
within(".pagination") { click_on "2" }
19-
expect(page).to have_selector('tr.editable', count: 1)
19+
within('.pagination-per-page') { click_link '3' }
20+
within('.pagination') { click_link '2' }
21+
expect(page).to have_css('tr.editable', count: 1)
2022
end
2123

2224
scenario 'The user sort users and change page', js: true do
2325
visit admin_users_path
2426

2527
find('.name a.sortable').click
26-
expect(page).to have_content("Aaron")
27-
expect(page).to_not have_content("Jane")
28+
expect(page).to have_content('Aaron')
29+
expect(page).to_not have_content('Jane')
2830

29-
within(".pagination") { click_on "2" }
30-
expect(page).to have_content("Jane")
31-
expect(page).to_not have_content("Aaron")
31+
within('.pagination') { click_link '2' }
32+
expect(page).to have_content('Jane')
33+
expect(page).to_not have_content('Aaron')
3234
end
3335

3436
scenario 'The user combine filters', js: true do
3537
visit admin_users_path
3638

37-
fill_in "filter", with: "email"
39+
fill_in 'filter', with: 'email'
3840
find('input#boolean').click
39-
expect(page).to have_selector('tr.editable', count: 2)
41+
expect(page).to have_css('tr.editable', count: 2)
4042
end
4143

4244
scenario 'The user combine filters and sort users', js: true do
4345
visit admin_users_path
4446

45-
fill_in "filter", with: "test"
47+
fill_in 'filter', with: 'test'
4648
find('input#boolean').click
4749
wait_for_ajax
48-
expect(page).to have_selector('tr.editable', count: 2)
50+
expect(page).to have_css('tr.editable', count: 2)
4951

5052
click_link 'Name'
51-
expect(page).to have_selector('tr.editable', count: 2)
52-
expect(page.find(:css, "tbody > tr:nth-child(1)")).to have_content("Edward")
53-
expect(page.find(:css, "tbody > tr:nth-child(2)")).to have_content("Robin")
53+
expect(page).to have_css('tr.editable', count: 2)
54+
expect(page.find(:css, 'tbody > tr:nth-child(1)')).to have_content('Edward')
55+
expect(page.find(:css, 'tbody > tr:nth-child(2)')).to have_content('Robin')
5456
end
5557

5658
scenario 'The user combine filters, sort and change page', js: true do
5759
visit admin_users_path
5860

5961
check 'boolean'
6062
wait_for_ajax
61-
expect(find(:css, '.email a.sortable')[:href]).to include("boolean")
63+
expect(find(:css, '.email a.sortable')[:href]).to include('boolean')
6264

6365
click_link 'Email'
64-
expect(page.find(:css, "tbody > tr:nth-child(2)")).to have_content("Lisa")
66+
expect(page.find(:css, 'tbody > tr:nth-child(2)')).to have_content('Lisa')
6567

66-
within(".pagination") { click_on "2" }
67-
expect(page.find(:css, "tbody > tr:nth-child(1)")).to have_content("Robin")
68-
expect(page.find(:css, '.count')).to have_content("4")
68+
within('.pagination') { click_link '2' }
69+
expect(page.find(:css, 'tbody > tr:nth-child(1)')).to have_content('Robin')
70+
expect(page.find(:css, '.count')).to have_content('4')
6971
end
7072
end

spec/features/manage_items_spec.rb

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

3-
RSpec.feature "Manage items" do
4-
scenario "Add a new item", js: true do
5+
RSpec.feature 'Manage items' do
6+
scenario 'Add a new item', js: true do
57
visit admin_users_path
68

7-
click_on "New item"
8-
fill_in "Name", with: "Test name"
9-
fill_in "Email", with: "Test email"
10-
click_on "Save"
9+
click_link 'New item'
10+
fill_in 'Name', with: 'Test name'
11+
fill_in 'Email', with: 'Test email'
12+
click_button 'Save'
1113

12-
expect(page).to have_content("Test name")
14+
expect(page).to have_content('Test name')
1315
end
1416

15-
scenario "Edit an item", js: true do
16-
User.create(name: "Name 1", email: "Email 1")
17+
scenario 'Edit an item', js: true do
18+
User.create(name: 'Name 1', email: 'Email 1')
1719
visit admin_users_path
1820

1921
find('.edit').click
20-
fill_in "Name", with: "Name 2"
21-
fill_in "Email", with: "Email 2"
22-
click_on "Save"
22+
fill_in 'Name', with: 'Name 2'
23+
fill_in 'Email', with: 'Email 2'
24+
click_button 'Save'
2325

24-
expect(page).to have_content("Name 2")
25-
expect(page).to_not have_content("Name 1")
26+
expect(page).to have_content('Name 2')
27+
expect(page).to_not have_content('Name 1')
2628
end
2729

28-
scenario "Delete an item", js: true do
29-
User.create(name: "Name 1", email: "Email 1")
30+
scenario 'Delete an item', js: true do
31+
User.create(name: 'Name 1', email: 'Email 1')
3032

3133
visit admin_users_path
3234
find('.destroy').click
33-
within('.confirmation_box') { click_on "Yes" }
35+
within('.confirmation_box') { click_button 'Yes' }
3436

35-
expect(page).to_not have_content("Name 1")
37+
expect(page).to_not have_content('Name 1')
3638
end
3739

38-
scenario "Use a custom action", js: true do
39-
User.create(name: "Name 1", email: "Email 1")
40+
scenario 'Use a custom action', js: true do
41+
User.create(name: 'Name 1', email: 'Email 1')
4042

4143
visit admin_users_path
4244
find('.change_name').click
4345

44-
expect(page).to have_content("Changed Name")
46+
expect(page).to have_content('Changed Name')
4547
end
4648
end

spec/features/view_items_spec.rb

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
RSpec.feature 'View a list of items' do
@@ -6,39 +8,39 @@
68
scenario 'The user navigate through users', js: true do
79
visit root_path
810

9-
#page_sizes => [3, 10]
10-
expect(page).to have_content("Betty")
11-
expect(page).to_not have_content("Edward")
11+
# page_sizes => [3, 10]
12+
expect(page).to have_content('Betty')
13+
expect(page).to_not have_content('Edward')
1214

13-
within(".pagination") { click_on "2" }
15+
within('.pagination') { click_link '2' }
1416

15-
expect(page).to have_content("Edward")
16-
expect(page).to_not have_content("Betty")
17+
expect(page).to have_content('Edward')
18+
expect(page).to_not have_content('Betty')
1719
end
1820

19-
scenario "The user sort users", js: true do
21+
scenario 'The user sort users', js: true do
2022
visit sortable_users_path
2123

2224
find('.name a').click
23-
expect(find(:xpath, "//table/tbody/tr[1]")).to have_content("Aaron")
24-
expect(find(:xpath, "//table/tbody/tr[2]")).to have_content("Betty")
25+
expect(find(:xpath, '//table/tbody/tr[1]')).to have_content('Aaron')
26+
expect(find(:xpath, '//table/tbody/tr[2]')).to have_content('Betty')
2527

2628
find('.name a').click
27-
expect(find(:xpath, "//table/tbody/tr[1]")).to have_content("Sara")
28-
expect(find(:xpath, "//table/tbody/tr[2]")).to have_content("Robin")
29+
expect(find(:xpath, '//table/tbody/tr[1]')).to have_content('Sara')
30+
expect(find(:xpath, '//table/tbody/tr[2]')).to have_content('Robin')
2931
end
3032

31-
scenario "The user search user", js: true do
33+
scenario 'The user search user', js: true do
3234
visit admin_users_path
3335

34-
fill_in "filter", with: "ja"
36+
fill_in 'filter', with: 'ja'
3537

36-
expect(page).to have_content("Jane")
37-
expect(page).to_not have_content("Aaron")
38+
expect(page).to have_content('Jane')
39+
expect(page).to_not have_content('Aaron')
3840

39-
fill_in "filter", with: "ni"
41+
fill_in 'filter', with: 'ni'
4042

41-
expect(page).to_not have_content("Nicholas")
42-
expect(page).to_not have_content("Jane")
43+
expect(page).to_not have_content('Nicholas')
44+
expect(page).to_not have_content('Jane')
4345
end
4446
end

0 commit comments

Comments
 (0)