Skip to content

Commit 0e1d92a

Browse files
committed
Rubocop fixes
1 parent e623c52 commit 0e1d92a

File tree

13 files changed

+101
-45
lines changed

13 files changed

+101
-45
lines changed

spec/concerns/better_together/seedable_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
module BetterTogether
66
describe Seedable, type: :model do
77
# Define a test ActiveRecord model inline for this spec
8+
# rubocop:todo RSpec/LeakyConstantDeclaration
89
class TestSeedableClass < ApplicationRecord # rubocop:todo Lint/ConstantDefinitionInBlock
910
include Seedable
1011
end
12+
# rubocop:enable RSpec/LeakyConstantDeclaration
1113

12-
before(:all) do
14+
before(:all) do # rubocop:todo RSpec/BeforeAfterAll
1315
create_table(:better_together_test_seedable_classes) do |t|
1416
t.string :name
1517
end
1618
end
1719

18-
after(:all) do
20+
after(:all) do # rubocop:todo RSpec/BeforeAfterAll
1921
drop_table(:better_together_test_seedable_classes)
2022
end
2123

spec/models/better_together/seed_spec.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,33 @@
8686
end
8787

8888
context 'when the source is a direct file path' do
89-
context 'and the file exists' do
89+
# rubocop:todo RSpec/NestedGroups
90+
context 'and the file exists' do # rubocop:todo RSpec/ContextWording, RSpec/NestedGroups
91+
# rubocop:enable RSpec/NestedGroups
9092
before do
9193
allow(File).to receive(:exist?).with(file_path).and_return(true)
9294
allow(YAML).to receive(:load_file).with(file_path).and_return(valid_seed_data)
9395
end
9496

95-
it 'imports the seed and returns a BetterTogether::Seed record' do
97+
it 'imports the seed and returns a BetterTogether::Seed record' do # rubocop:todo RSpec/MultipleExpectations
9698
result = described_class.load_seed(file_path)
9799
expect(result).to be_a(described_class)
98100
expect(result.identifier).to eq('from_test')
99101
expect(result.payload[:payload_key]).to eq('payload_value')
100102
end
101103
end
102104

103-
context 'but the file does not exist' do
105+
# rubocop:todo RSpec/NestedGroups
106+
context 'but the file does not exist' do # rubocop:todo RSpec/ContextWording, RSpec/NestedGroups
107+
# rubocop:enable RSpec/NestedGroups
104108
it 'falls back to namespace logic and raises an error' do
105109
expect do
106110
described_class.load_seed(file_path)
107111
end.to raise_error(RuntimeError, /Seed file not found for/)
108112
end
109113
end
110114

111-
context 'when YAML loading raises an error' do
115+
context 'when YAML loading raises an error' do # rubocop:todo RSpec/NestedGroups
112116
before do
113117
allow(File).to receive(:exist?).with(file_path).and_return(true)
114118
allow(YAML).to receive(:load_file).with(file_path).and_raise(StandardError, 'Bad YAML')
@@ -126,21 +130,25 @@
126130
let(:namespace) { 'better_together/wizards/host_setup_wizard' }
127131
let(:full_path) { Rails.root.join('config', 'seeds', "#{namespace}.yml").to_s }
128132

129-
context 'and the file exists' do
133+
# rubocop:todo RSpec/NestedGroups
134+
context 'and the file exists' do # rubocop:todo RSpec/ContextWording, RSpec/NestedGroups
135+
# rubocop:enable RSpec/NestedGroups
130136
before do
131137
allow(File).to receive(:exist?).with(namespace).and_return(false)
132138
allow(File).to receive(:exist?).with(full_path).and_return(true)
133139
allow(YAML).to receive(:load_file).with(full_path).and_return(valid_seed_data)
134140
end
135141

136-
it 'imports the seed from the namespace path' do
142+
it 'imports the seed from the namespace path' do # rubocop:todo RSpec/MultipleExpectations
137143
result = described_class.load_seed(namespace)
138144
expect(result).to be_a(described_class)
139145
expect(result.identifier).to eq('from_test')
140146
end
141147
end
142148

143-
context 'but the file does not exist' do
149+
# rubocop:todo RSpec/NestedGroups
150+
context 'but the file does not exist' do # rubocop:todo RSpec/ContextWording, RSpec/NestedGroups
151+
# rubocop:enable RSpec/NestedGroups
144152
before do
145153
allow(File).to receive(:exist?).with(namespace).and_return(false)
146154
allow(File).to receive(:exist?).with(full_path).and_return(false)
@@ -153,7 +161,7 @@
153161
end
154162
end
155163

156-
context 'when YAML loading raises an error' do
164+
context 'when YAML loading raises an error' do # rubocop:todo RSpec/NestedGroups
157165
before do
158166
allow(File).to receive(:exist?).with(namespace).and_return(false)
159167
allow(File).to receive(:exist?).with(full_path).and_return(true)
@@ -178,7 +186,7 @@
178186
create(:better_together_seed)
179187
end
180188

181-
it 'attaches a YAML file after creation' do
189+
it 'attaches a YAML file after creation' do # rubocop:todo RSpec/NoExpectationExample
182190
# seed.reload # Ensures the record reloads from the DB after the commit callback
183191
# expect(seed.yaml_file).to be_attached
184192

spec/requests/better_together/person_platform_integrations_spec.rb

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@
2626
skip('Add a hash of attributes invalid for your model')
2727
end
2828

29-
describe 'GET /index' do
30-
it 'renders a successful response' do
29+
describe 'GET /index' do # rubocop:todo RSpec/RepeatedExampleGroupBody
30+
it 'renders a successful response' do # rubocop:todo RSpec/NoExpectationExample
3131
# BetterTogether::PersonPlatformIntegration.create! valid_attributes
3232
# get person_platform_integrations_url
3333
# expect(response).to be_successful
3434
end
3535
end
3636

37-
describe 'GET /show' do
38-
it 'renders a successful response' do
37+
describe 'GET /show' do # rubocop:todo RSpec/RepeatedExampleGroupBody
38+
it 'renders a successful response' do # rubocop:todo RSpec/NoExpectationExample
3939
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
4040
# get person_platform_integration_url(authorization)
4141
# expect(response).to be_successful
4242
end
4343
end
4444

45-
describe 'GET /new' do
46-
it 'renders a successful response' do
45+
describe 'GET /new' do # rubocop:todo RSpec/RepeatedExampleGroupBody
46+
it 'renders a successful response' do # rubocop:todo RSpec/NoExpectationExample
4747
# get new_person_platform_integration_url
4848
# expect(response).to be_successful
4949
end
5050
end
5151

52-
describe 'GET /edit' do
53-
it 'renders a successful response' do
52+
describe 'GET /edit' do # rubocop:todo RSpec/RepeatedExampleGroupBody
53+
it 'renders a successful response' do # rubocop:todo RSpec/NoExpectationExample
5454
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
5555
# get edit_person_platform_integration_url(authorization)
5656
# expect(response).to be_successful
@@ -59,30 +59,40 @@
5959

6060
describe 'POST /create' do
6161
context 'with valid parameters' do
62-
it 'creates a new BetterTogether::PersonPlatformIntegration' do
62+
# rubocop:todo RSpec/RepeatedExample
63+
it 'creates a new BetterTogether::PersonPlatformIntegration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
6364
# expect do
6465
# post person_platform_integrations_url, params: { person_platform_integration: valid_attributes }
6566
# end.to change(BetterTogether::PersonPlatformIntegration, :count).by(1)
6667
end
68+
# rubocop:enable RSpec/RepeatedExample
6769

68-
it 'redirects to the created person_platform_integration' do
70+
# rubocop:todo RSpec/RepeatedExample
71+
it 'redirects to the created person_platform_integration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
6972
# post person_platform_integrations_url, params: { person_platform_integration: valid_attributes }
7073
# expect(response).to
7174
# redirect_to(person_platform_integration_url(BetterTogether::PersonPlatformIntegration.last))
7275
end
76+
# rubocop:enable RSpec/RepeatedExample
7377
end
7478

7579
context 'with invalid parameters' do
76-
it 'does not create a new BetterTogether::PersonPlatformIntegration' do
80+
# rubocop:todo RSpec/RepeatedExample
81+
it 'does not create a new BetterTogether::PersonPlatformIntegration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
7782
# expect do
7883
# post person_platform_integrations_url, params: { person_platform_integration: invalid_attributes }
7984
# end.to change(BetterTogether::PersonPlatformIntegration, :count).by(0)
8085
end
86+
# rubocop:enable RSpec/RepeatedExample
8187

88+
# rubocop:todo RSpec/RepeatedExample
89+
# rubocop:todo RSpec/NoExpectationExample
8290
it "renders a response with 422 status (i.e. to display the 'new' template)" do
8391
# post person_platform_integrations_url, params: { person_platform_integration: invalid_attributes }
8492
# expect(response).to have_http_status(:unprocessable_entity)
8593
end
94+
# rubocop:enable RSpec/NoExpectationExample
95+
# rubocop:enable RSpec/RepeatedExample
8696
end
8797
end
8898

@@ -92,43 +102,53 @@
92102
skip('Add a hash of attributes valid for your model')
93103
end
94104

95-
it 'updates the requested person_platform_integration' do
105+
# rubocop:todo RSpec/RepeatedExample
106+
it 'updates the requested person_platform_integration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
96107
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
97108
# patch person_platform_integration_url(authorization), params: { person_platform_integration: new_attributes }
98109
# authorization.reload
99110
# skip('Add assertions for updated state')
100111
end
112+
# rubocop:enable RSpec/RepeatedExample
101113

102-
it 'redirects to the person_platform_integration' do
114+
# rubocop:todo RSpec/RepeatedExample
115+
it 'redirects to the person_platform_integration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
103116
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
104117
# patch person_platform_integration_url(authorization), params: { person_platform_integration: new_attributes }
105118
# authorization.reload
106119
# expect(response).to redirect_to(person_platform_integration_url(authorization))
107120
end
121+
# rubocop:enable RSpec/RepeatedExample
108122
end
109123

110124
context 'with invalid parameters' do
125+
# rubocop:todo RSpec/NoExpectationExample
111126
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
112127
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
113128
# patch person_platform_integration_url(authorization),
114129
# params: { person_platform_integration: invalid_attributes }
115130
# expect(response).to have_http_status(:unprocessable_entity)
116131
end
132+
# rubocop:enable RSpec/NoExpectationExample
117133
end
118134
end
119135

120136
describe 'DELETE /destroy' do
121-
it 'destroys the requested person_platform_integration' do
137+
# rubocop:todo RSpec/RepeatedExample
138+
it 'destroys the requested person_platform_integration' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
122139
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
123140
# expect do
124141
# delete person_platform_integration_url(authorization)
125142
# end.to change(BetterTogether::PersonPlatformIntegration, :count).by(-1)
126143
end
144+
# rubocop:enable RSpec/RepeatedExample
127145

128-
it 'redirects to the person_platform_integrations list' do
146+
# rubocop:todo RSpec/RepeatedExample
147+
it 'redirects to the person_platform_integrations list' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
129148
# authorization = BetterTogether::PersonPlatformIntegration.create! valid_attributes
130149
# delete person_platform_integration_url(authorization)
131150
# expect(response).to redirect_to(person_platform_integrations_url)
132151
end
152+
# rubocop:enable RSpec/RepeatedExample
133153
end
134154
end

spec/routing/better_together/person_platform_integrations_routing_spec.rb

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,62 @@
44

55
RSpec.describe BetterTogether::PersonPlatformIntegrationsController do
66
describe 'routing' do
7-
it 'routes to #index' do
7+
# rubocop:todo RSpec/RepeatedExample
8+
it 'routes to #index' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
89
# expect(get: '/better_together/authorizations').to route_to('better_together/authorizations#index')
910
end
11+
# rubocop:enable RSpec/RepeatedExample
1012

11-
it 'routes to #new' do
13+
# rubocop:todo RSpec/RepeatedExample
14+
it 'routes to #new' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
1215
# expect(get: '/better_together/authorizations/new').to route_to('better_together/authorizations#new')
1316
end
17+
# rubocop:enable RSpec/RepeatedExample
1418

15-
it 'routes to #show' do
19+
# rubocop:todo RSpec/RepeatedExample
20+
it 'routes to #show' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
21+
# rubocop:todo Layout/LineLength
1622
# expect(get: '/better_together/authorizations/1').to route_to('better_together/authorizations#show', id: '1')
23+
# rubocop:enable Layout/LineLength
1724
end
25+
# rubocop:enable RSpec/RepeatedExample
1826

19-
it 'routes to #edit' do
27+
# rubocop:todo RSpec/RepeatedExample
28+
it 'routes to #edit' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
29+
# rubocop:todo Layout/LineLength
2030
# expect(get: '/better_together/authorizations/1/edit').toroute_to('better_together/authorizations#edit', id: '1')
31+
# rubocop:enable Layout/LineLength
2132
end
33+
# rubocop:enable RSpec/RepeatedExample
2234

23-
it 'routes to #create' do
35+
# rubocop:todo RSpec/RepeatedExample
36+
it 'routes to #create' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
2437
# expect(post: '/better_together/authorizations').to route_to('better_together/authorizations#create')
2538
end
39+
# rubocop:enable RSpec/RepeatedExample
2640

27-
it 'routes to #update via PUT' do
41+
# rubocop:todo RSpec/RepeatedExample
42+
it 'routes to #update via PUT' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
43+
# rubocop:todo Layout/LineLength
2844
# expect(put: '/better_together/authorizations/1').to route_to('better_together/authorizations#update', id: '1')
45+
# rubocop:enable Layout/LineLength
2946
end
47+
# rubocop:enable RSpec/RepeatedExample
3048

31-
it 'routes to #update via PATCH' do
49+
# rubocop:todo RSpec/RepeatedExample
50+
it 'routes to #update via PATCH' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
51+
# rubocop:todo Layout/LineLength
3252
# expect(patch: '/better_together/authorizations/1').to route_to('better_together/authorizations#update', id: '1')
53+
# rubocop:enable Layout/LineLength
3354
end
55+
# rubocop:enable RSpec/RepeatedExample
3456

35-
it 'routes to #destroy' do
57+
# rubocop:todo RSpec/RepeatedExample
58+
it 'routes to #destroy' do # rubocop:todo RSpec/NoExpectationExample, RSpec/RepeatedExample
59+
# rubocop:todo Layout/LineLength
3660
# expect(delete: '/better_together/authorizations/1').toroute_to('better_together/authorizations#destroy',id: '1')
61+
# rubocop:enable Layout/LineLength
3762
end
63+
# rubocop:enable RSpec/RepeatedExample
3864
end
3965
end

spec/support/shared_examples/a_seedable_model.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
end
3636

3737
describe '#export_as_seed_yaml' do
38-
it 'returns a valid YAML string' do
38+
it 'returns a valid YAML string' do # rubocop:todo RSpec/MultipleExpectations
3939
yaml_str = record.export_as_seed_yaml
4040
expect(yaml_str).to be_a(String)
4141
expect(yaml_str).to include(BetterTogether::Seed::DEFAULT_ROOT_KEY.to_s)
@@ -60,7 +60,7 @@
6060
expect(collection_hash.keys).to include(BetterTogether::Seed::DEFAULT_ROOT_KEY)
6161
end
6262

63-
it 'includes an array of records under :records' do
63+
it 'includes an array of records under :records' do # rubocop:todo RSpec/MultipleExpectations
6464
collection_hash = described_class.export_collection_as_seed(records)
6565
root_key = collection_hash.keys.first
6666
expect(collection_hash[root_key]).to have_key(:records)
@@ -70,7 +70,7 @@
7070
end
7171

7272
describe '.export_collection_as_seed_yaml' do
73-
it 'returns a valid YAML string' do
73+
it 'returns a valid YAML string' do # rubocop:todo RSpec/MultipleExpectations
7474
yaml_str = described_class.export_collection_as_seed_yaml(records)
7575
expect(yaml_str).to be_a(String)
7676
expect(yaml_str).to include(BetterTogether::Seed::DEFAULT_ROOT_KEY.to_s)

spec/views/better_together/person_platform_integrations/edit.html.erb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
assign(:person_platform_integration, person_platform_integration)
1212
end
1313

14-
it 'renders the edit person_platform_integration form' do
14+
it 'renders the edit person_platform_integration form' do # rubocop:todo RSpec/NoExpectationExample
1515
# render
1616

1717
# assert_select 'form[action=?][method=?]', person_platform_integration_path(person_platform_integration), 'post' do

spec/views/better_together/person_platform_integrations/index.html.erb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
assign(:person_platform_integrations, create_list(:person_platform_integration, 3))
88
end
99

10-
it 'renders a list of better_together/authorizations' do
10+
it 'renders a list of better_together/authorizations' do # rubocop:todo RSpec/NoExpectationExample
1111
# render
1212
# cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
1313
# assert_select cell_selector, text: Regexp.new('Provider'.to_s), count: 2

spec/views/better_together/person_platform_integrations/new.html.erb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
assign(:person_platform_integration, create(:person_platform_integration))
88
end
99

10-
it 'renders new person_platform_integration form' do
10+
it 'renders new person_platform_integration form' do # rubocop:todo RSpec/NoExpectationExample
1111
# render
1212

1313
# assert_select 'form[action=?][method=?]', person_platform_integrations_path, 'post' do

spec/views/better_together/person_platform_integrations/show.html.erb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
assign(:person_platform_integration, create(:person_platform_integration))
88
end
99

10-
it 'renders attributes in <p>' do
10+
it 'renders attributes in <p>' do # rubocop:todo RSpec/NoExpectationExample
1111
# render
1212
# expect(rendered).to match(/Provider/)
1313
# expect(rendered).to match(/Uid/)

spec/views/better_together/seeds/edit.html.erb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
assign(:seed, seed)
1212
end
1313

14-
it 'renders the edit seed form' do
14+
it 'renders the edit seed form' do # rubocop:todo RSpec/NoExpectationExample
1515
# render
1616

1717
# assert_select "form[action=?][method=?]", seed_path(seed), "post" do

0 commit comments

Comments
 (0)