Skip to content

Commit 4d243c4

Browse files
committed
Run rubocop -a in core/spec
1 parent ec0685d commit 4d243c4

File tree

164 files changed

+1635
-1458
lines changed

Some content is hidden

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

164 files changed

+1635
-1458
lines changed

.rubocop-disabled.yml

+12
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,15 @@ RSpec/MultipleExpectations:
3535

3636
RSpec/FilePath:
3737
Enabled: false
38+
39+
RSpec/LetSetup:
40+
Enabled: false
41+
42+
RSpec/SubjectStub:
43+
Enabled: false
44+
45+
RSpec/VoidExpect:
46+
Enabled: false
47+
48+
RSpec/BeforeAfterAll:
49+
Enabled: false

.rubocop.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ ModuleLength:
3535
Documentation:
3636
Enabled: false
3737

38-
LineLength:
38+
Metrics/LineLength:
3939
Max: 150
40+
Exclude:
41+
- '**/spec/**/*'
4042

4143
MethodLength:
4244
CountComments: false

api/spec/controllers/spree/api/v1/payments_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module Spree
105105
it 'can update' do
106106
payment.update_attributes(state: 'checkout')
107107
api_put(:update, id: payment.to_param, payment: { amount: 2.01 })
108-
expect(response.status).to be(200)
108+
expect(response.status).to eq(200)
109109
expect(payment.reload.amount).to eq(2.01)
110110
end
111111
end

api/spec/controllers/spree/api/v1/stores_controller_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ module Spree
1919
create(:store,
2020
name: 'Extra Store',
2121
url: 'spreestore-5.example.com',
22-
default: false
23-
)
22+
default: false)
2423
end
2524

2625
it 'I can list the available stores' do

api/spec/controllers/spree/api/v1/taxons_controller_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module Spree
5858

5959
context 'searching for top level taxon' do
6060
let(:name) { 'Ruby' }
61+
6162
it 'returns the matching taxons' do
6263
expect_single_taxon_result 'Ruby'
6364
end

api/spec/controllers/spree/api/v1/unauthenticated_products_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Spree
55
describe Api::V1::ProductsController, type: :controller do
66
render_views
77

8-
let!(:product) { create(:product) } # rubocop:disable RSpec/LetSetup
8+
let!(:product) { create(:product) }
99
let(:attributes) { [:id, :name, :description, :price, :available_on, :slug, :meta_description, :meta_keywords, :taxon_ids] }
1010

1111
context 'without authentication' do

api/spec/controllers/spree/api/v1/users_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module Spree
8787
assert_not_found!
8888
end
8989

90-
it 'onlies get own details on index' do
90+
it 'only gets own details on index' do
9191
2.times { create(:user) }
9292
api_get :index, token: user.spree_api_key
9393

api/spec/controllers/spree/api/v1/variants_controller_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ module Spree
2222

2323
describe '#variant_includes' do
2424
let(:variants_includes_list) do
25-
[{ option_values: :option_type }, :product,
26-
:default_price, :images, { stock_items: :stock_location }]
25+
[{ option_values: :option_type }, :product, :default_price, :images, { stock_items: :stock_location }]
2726
end
27+
2828
it { expect(controller).to receive(:variant_includes).and_return(variants_includes_list) }
2929
after { api_get :index }
3030
end

backend/spec/controllers/spree/admin/resource_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def model_class
1515
describe Spree::Admin::DummyModelsController, type: :controller do
1616
stub_authorization!
1717

18-
after(:all) do # rubocop:disable RSpec/BeforeAfterAll
18+
after(:all) do
1919
Rails.application.reload_routes!
2020
end
2121

backend/spec/features/admin/configuration/states_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def go_to_states_page
1818
context 'admin visiting states listing' do
1919
let!(:state) { create(:state, country: country) }
2020

21-
it 'correctlies display the states' do
21+
it 'correctly displays the states' do
2222
visit spree.admin_country_states_path(country)
2323
expect(page).to have_content(state.name)
2424
end

backend/spec/features/admin/orders/payments_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def refresh_page
2828
context 'with a check payment' do
2929
let(:order) { create(:completed_order_with_totals, number: 'R100') }
3030

31-
let!(:payment) do # rubocop:disable RSpec/LetSetup
31+
let!(:payment) do
3232
create(:payment,
3333
order: order,
3434
amount: order.outstanding_balance,
@@ -211,7 +211,7 @@ def refresh_page
211211
end
212212

213213
context 'with a check' do
214-
let!(:payment_method) { create(:check_payment_method) } # rubocop:disable RSpec/LetSetup
214+
let!(:payment_method) { create(:check_payment_method) }
215215

216216
before do
217217
visit spree.admin_order_payments_path(order.reload)

backend/spec/features/admin/products/products_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def build_option_type_with_values(name, values)
410410
end
411411
let!(:product) { create(:product) }
412412

413-
it 'onlies display accessible links on index' do
413+
it 'only displays accessible links on index' do
414414
visit spree.admin_products_path
415415

416416
expect(page).to have_link('Products')
@@ -423,7 +423,7 @@ def build_option_type_with_values(name, values)
423423
expect(page).not_to have_css('.delete-resource')
424424
end
425425

426-
it 'onlies display accessible links on edit' do
426+
it 'only displays accessible links on edit' do
427427
visit spree.admin_product_path(product)
428428

429429
# product tabs should be hidden

core/spec/helpers/base_helper_spec.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@
5353
# Regression test for #1436
5454
context 'defining custom image helpers' do
5555
let(:product) { mock_model(Spree::Product, images: [], variant_images: []) }
56+
5657
before do
5758
Spree::Image.class_eval do
5859
attachment_definitions[:attachment][:styles].merge!(very_strange: '1x1')
5960
end
6061
end
6162

62-
it 'should not raise errors when style exists' do
63+
it 'does not raise errors when style exists' do
6364
expect { very_strange_image(product) }.not_to raise_error
6465
end
6566

66-
it 'should raise NoMethodError when style is not exists' do
67+
it 'raises NoMethodError when style is not exists' do
6768
expect { another_strange_image(product) }.to raise_error(NoMethodError)
6869
end
6970
end
@@ -114,24 +115,25 @@ def link_to_tracking_html(options = {})
114115
# Regression test for #5384
115116
context 'custom image helpers conflict with inproper statements' do
116117
let(:product) { mock_model(Spree::Product, images: [], variant_images: []) }
118+
117119
before do
118120
Spree::Image.class_eval do
119121
attachment_definitions[:attachment][:styles].merge!(foobar: '1x1')
120122
end
121123
end
122124

123-
it 'should not raise errors when helper method called' do
125+
it 'does not raise errors when helper method called' do
124126
expect { foobar_image(product) }.not_to raise_error
125127
end
126128

127-
it 'should raise NoMethodError when statement with name equal to style name called' do
129+
it 'raises NoMethodError when statement with name equal to style name called' do
128130
expect { foobar(product) }.to raise_error(NoMethodError)
129131
end
130132
end
131133

132134
context 'pretty_time' do
133135
it 'prints in a format' do
134-
expect(pretty_time(DateTime.new(2012, 5, 6, 13, 33))).to eq 'May 06, 2012 1:33 PM'
136+
expect(pretty_time(Time.new(2012, 5, 6, 13, 33))).to eq 'May 06, 2012 1:33 PM'
135137
end
136138
end
137139

core/spec/helpers/products_helper_spec.rb

+26-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
require 'spec_helper'
42

53
module Spree
@@ -14,6 +12,8 @@ module Spree
1412
end
1513

1614
context '#variant_price_diff' do
15+
subject { helper.variant_price(@variant) }
16+
1717
let(:product_price) { 10 }
1818
let(:variant_price) { 10 }
1919

@@ -25,8 +25,6 @@ module Spree
2525
allow(@variant).to receive(:amount_in) { variant_price }
2626
end
2727

28-
subject { helper.variant_price(@variant) }
29-
3028
context 'when variant is same as master' do
3129
it { is_expected.to be_nil }
3230
end
@@ -80,7 +78,7 @@ module Spree
8078
end
8179

8280
context 'when currency is default' do
83-
it 'should return the variant price if the price is different than master' do
81+
it 'returns the variant price if the price is different than master' do
8482
product.price = 10
8583
@variant1.price = 15
8684
@variant2.price = 20
@@ -101,14 +99,14 @@ module Spree
10199
end
102100
end
103101

104-
it 'should return the variant price if the price is different than master' do
102+
it 'returns the variant price if the price is different than master' do
105103
product.price = 100
106104
@variant1.price = 150
107105
expect(helper.variant_price(@variant1)).to eq('¥150')
108106
end
109107
end
110108

111-
it 'should be nil when all variant prices are equal' do
109+
it 'is nil when all variant prices are equal' do
112110
product.price = 10
113111
@variant1.default_price.update_column(:amount, 10)
114112
@variant2.default_price.update_column(:amount, 10)
@@ -142,19 +140,19 @@ module Spree
142140
end
143141

144142
it 'renders a product description without any formatting based on configuration' do
145-
initialDescription = %Q{
143+
initial_description = %Q{
146144
<p>hello world</p>
147145
148146
<p>tihs is completely awesome and it works</p>
149147
150148
<p>why so many spaces in the code. and why some more formatting afterwards?</p>
151149
}
152150

153-
product.description = initialDescription
151+
product.description = initial_description
154152

155153
Spree::Config[:show_raw_product_description] = true
156154
description = product_description(product)
157-
expect(description).to eq(initialDescription)
155+
expect(description).to eq(initial_description)
158156
end
159157

160158
context 'renders a product description default description incase description is blank' do
@@ -166,43 +164,49 @@ module Spree
166164
shared_examples_for 'line item descriptions' do
167165
context 'variant has a blank description' do
168166
let(:description) { nil }
167+
169168
it { is_expected.to eq(Spree.t(:product_has_no_description)) }
170169
end
171170
context 'variant has a description' do
172171
let(:description) { 'test_desc' }
172+
173173
it { is_expected.to eq(description) }
174174
end
175175
context 'description has nonbreaking spaces' do
176176
let(:description) { 'test&nbsp;desc' }
177+
177178
it { is_expected.to eq('test desc') }
178179
end
179180
context 'description has line endings' do
180181
let(:description) { "test\n\r\ndesc" }
182+
181183
it { is_expected.to eq('test desc') }
182184
end
183185
end
184186

185187
context '#line_item_description_text' do
186188
subject { line_item_description_text description }
187189

188-
it_should_behave_like 'line item descriptions'
190+
it_behaves_like 'line item descriptions'
189191
end
190192

191193
context '#cache_key_for_products' do
194+
subject { helper.cache_key_for_products }
195+
192196
let(:zone) { Spree::Zone.new }
193197
let(:price_options) { { tax_zone: zone } }
194198

195-
subject { helper.cache_key_for_products }
196-
before(:each) do
199+
before do
197200
@products = double('products collection')
198-
allow(helper).to receive(:params) { { page: 10 } }
201+
allow(helper).to receive(:params).and_return(page: 10)
199202
allow(helper).to receive(:current_price_options) { price_options }
200203
end
201204

202205
context 'when there is a maximum updated date' do
203206
let(:updated_at) { Date.new(2011, 12, 13) }
204-
before :each do
205-
allow(@products).to receive(:count) { 5 }
207+
208+
before do
209+
allow(@products).to receive(:count).and_return(5)
206210
allow(@products).to receive(:maximum).with(:updated_at) { updated_at }
207211
end
208212

@@ -211,9 +215,10 @@ module Spree
211215

212216
context 'when there is no considered maximum updated date' do
213217
let(:today) { Date.new(2013, 12, 11) }
214-
before :each do
215-
allow(@products).to receive(:count) { 1_234_567 }
216-
allow(@products).to receive(:maximum).with(:updated_at) { nil }
218+
219+
before do
220+
allow(@products).to receive(:count).and_return(1_234_567)
221+
allow(@products).to receive(:maximum).with(:updated_at).and_return(nil)
217222
allow(Date).to receive(:today) { today }
218223
end
219224

@@ -222,11 +227,11 @@ module Spree
222227
end
223228

224229
context '#cache_key_for_product' do
230+
subject(:cache_key) { helper.cache_key_for_product(product) }
231+
225232
let(:product) { Spree::Product.new }
226233
let(:price_options) { { tax_zone: zone } }
227234

228-
subject(:cache_key) { helper.cache_key_for_product(product) }
229-
230235
before do
231236
allow(helper).to receive(:current_price_options) { price_options }
232237
end
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
describe Spree::CalculatedAdjustments do
4-
it 'should add has_one :calculator relationship' do
4+
it 'adds has_one :calculator relationship' do
55
assert Spree::ShippingMethod.reflect_on_all_associations(:has_one).map(&:name).include?(:calculator)
66
end
77
end

core/spec/lib/i18n_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
before do
77
I18n.backend.store_translations(:en,
88
spree: {
9-
foo: 'bar',
10-
bar: {
11-
foo: 'bar within bar scope',
12-
invalid: nil,
13-
legacy_translation: 'back in the day...'
14-
},
15-
invalid: nil,
16-
legacy_translation: 'back in the day...'
17-
})
9+
foo: 'bar',
10+
bar: {
11+
foo: 'bar within bar scope',
12+
invalid: nil,
13+
legacy_translation: 'back in the day...'
14+
},
15+
invalid: nil,
16+
legacy_translation: 'back in the day...'
17+
})
1818
end
1919

2020
it 'translates within the spree scope' do

0 commit comments

Comments
 (0)