Skip to content

Commit a2ec899

Browse files
authored
Lint: Fix RSpec/NamedSubject (#761)
1 parent 62b5eb2 commit a2ec899

File tree

4 files changed

+36
-44
lines changed

4 files changed

+36
-44
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/active_record/migration_extensions/schema_statements_spec.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ class Item < ActiveRecord::Base; end
3636

3737
context "with default options" do
3838
describe "amount" do
39-
subject { Item.columns_hash["price_cents"] }
39+
let(:column) { Item.columns_hash["price_cents"] }
4040

41-
it { expect(subject.default.to_i).to eq(0) }
42-
it { expect(Item.new.public_send(subject.name)).to eq(0) }
43-
it { expect(subject.null).to be(false) }
44-
it { expect(subject.type).to eq(:integer) }
41+
it { expect(column.default.to_i).to eq(0) }
42+
it { expect(Item.new.public_send(column.name)).to eq(0) }
43+
it { expect(column.null).to be(false) }
44+
it { expect(column.type).to eq(:integer) }
4545
end
4646

4747
describe "currency" do
48-
subject { Item.columns_hash["price_currency"] }
48+
let(:column) { Item.columns_hash["price_currency"] }
4949

5050
# set in spec/dummy/config/initializers/money.rb
51-
it { expect(subject.default).to eq("EUR") }
51+
it { expect(column.default).to eq("EUR") }
5252

53-
it { expect(subject.null).to be(false) }
54-
it { expect(subject.type).to eq(:string) }
53+
it { expect(column.null).to be(false) }
54+
it { expect(column.type).to eq(:string) }
5555
end
5656
end
5757

@@ -62,14 +62,14 @@ class Item < ActiveRecord::Base; end
6262

6363
context "with full options" do
6464
describe "amount" do
65-
subject { Item.columns_hash["prefix_price_with_full_options_postfix"] }
66-
67-
it { expect(subject.default.to_i).to eq(1) }
68-
it { expect(Item.new.public_send(subject.name)).to eq(1) }
69-
it { expect(subject.null).to be(true) }
70-
it { expect(subject.type).to eq(:decimal) }
71-
it { expect(subject.precision).to eq(4) }
72-
it { expect(subject.scale).to eq(2) }
65+
let(:column) { Item.columns_hash["prefix_price_with_full_options_postfix"] }
66+
67+
it { expect(column.default.to_i).to eq(1) }
68+
it { expect(Item.new.public_send(column.name)).to eq(1) }
69+
it { expect(column.null).to be(true) }
70+
it { expect(column.type).to eq(:decimal) }
71+
it { expect(column.precision).to eq(4) }
72+
it { expect(column.scale).to eq(2) }
7373
end
7474

7575
describe "currency" do

spec/active_record/migration_extensions/table_spec.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ class Item < ActiveRecord::Base; end
3737

3838
context "with default options" do
3939
describe "amount" do
40-
subject { Item.columns_hash["price_cents"] }
40+
let(:column) { Item.columns_hash["price_cents"] }
4141

42-
it { expect(subject.default.to_i).to eq(0) }
43-
it { expect(Item.new.public_send(subject.name)).to eq(0) }
44-
it { expect(subject.null).to be(false) }
45-
it { expect(subject.type).to eq(:integer) }
42+
it { expect(column.default.to_i).to eq(0) }
43+
it { expect(Item.new.public_send(column.name)).to eq(0) }
44+
it { expect(column.null).to be(false) }
45+
it { expect(column.type).to eq(:integer) }
4646
end
4747

4848
describe "currency" do
49-
subject { Item.columns_hash["price_currency"] }
49+
let(:column) { Item.columns_hash["price_currency"] }
5050

5151
# set in spec/dummy/config/initializers/money.rb
52-
it { expect(subject.default).to eq("EUR") }
52+
it { expect(column.default).to eq("EUR") }
5353

54-
it { expect(subject.null).to be(false) }
55-
it { expect(subject.type).to eq(:string) }
54+
it { expect(column.null).to be(false) }
55+
it { expect(column.type).to eq(:string) }
5656
end
5757
end
5858

@@ -63,14 +63,14 @@ class Item < ActiveRecord::Base; end
6363

6464
context "with full options" do
6565
describe "amount" do
66-
subject { Item.columns_hash["prefix_price_with_full_options_postfix"] }
67-
68-
it { expect(subject.default.to_i).to eq(1) }
69-
it { expect(Item.new.public_send(subject.name)).to eq(1) }
70-
it { expect(subject.null).to be(true) }
71-
it { expect(subject.type).to eq(:decimal) }
72-
it { expect(subject.precision).to eq(4) }
73-
it { expect(subject.scale).to eq(2) }
66+
let(:column) { Item.columns_hash["prefix_price_with_full_options_postfix"] }
67+
68+
it { expect(column.default.to_i).to eq(1) }
69+
it { expect(Item.new.public_send(column.name)).to eq(1) }
70+
it { expect(column.null).to be(true) }
71+
it { expect(column.type).to eq(:decimal) }
72+
it { expect(column.precision).to eq(4) }
73+
it { expect(column.scale).to eq(2) }
7474
end
7575

7676
describe "currency" do

spec/active_record/monetizable_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def assert_monetized_attributes(monetized_attributes, expected_attributes)
913913
end
914914
let(:default_currency_lambda) { double("Default Currency Fallback") }
915915

916-
subject { service.read_monetized(:discount, :discount_cents, options) }
916+
let(:read_monetized) { service.read_monetized(:discount, :discount_cents, options) }
917917

918918
around(:each) do |example|
919919
service # Instantiate instance which relies on Money.default_currency
@@ -928,7 +928,7 @@ def assert_monetized_attributes(monetized_attributes, expected_attributes)
928928

929929
it "does not attempt to read the fallback default currency" do
930930
expect(default_currency_lambda).not_to receive(:read_currency)
931-
subject
931+
read_monetized
932932
end
933933
end
934934
end

0 commit comments

Comments
 (0)