Skip to content

Commit 4f4dd16

Browse files
authored
Merge pull request #2277 from yahonda/other_rubocop_rspec_cops
Enable `RSpec/BeNil` and `RSpec/BeEq` cops
2 parents 483e756 + 800cd1f commit 4f4dd16

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ Performance/OpenStruct:
283283
Enabled: true
284284

285285
# RuboCop RSpec cops
286+
RSpec/BeEq:
287+
Enabled: true
288+
289+
RSpec/BeNil:
290+
Enabled: true
291+
286292
RSpec/EmptyLineAfterExampleGroup:
287293
Enabled: true
288294

spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
it "should not use JDBC statement caching" do
4545
if ORACLE_ENHANCED_CONNECTION == :jdbc
4646
ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS)
47-
expect(ActiveRecord::Base.connection.raw_connection.getImplicitCachingEnabled).to eq(false)
47+
expect(ActiveRecord::Base.connection.raw_connection.getImplicitCachingEnabled).to be(false)
4848
expect(ActiveRecord::Base.connection.raw_connection.getStatementCacheSize).to eq(-1)
4949
end
5050
end
5151

5252
it "should use JDBC statement caching" do
5353
if ORACLE_ENHANCED_CONNECTION == :jdbc
5454
ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS.merge(jdbc_statement_cache_size: 100))
55-
expect(ActiveRecord::Base.connection.raw_connection.getImplicitCachingEnabled).to eq(true)
55+
expect(ActiveRecord::Base.connection.raw_connection.getImplicitCachingEnabled).to be(true)
5656
expect(ActiveRecord::Base.connection.raw_connection.getStatementCacheSize).to eq(100)
5757
# else: don't raise error if OCI connection has parameter "jdbc_statement_cache_size", still ignore it
5858
end

spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -996,12 +996,12 @@ class ::TestFraction < ActiveRecord::Base
996996

997997
it "should include virtual columns and not try to update them" do
998998
tf = TestFraction.columns.detect { |c| c.virtual? }
999-
expect(tf).not_to be nil
999+
expect(tf).not_to be_nil
10001000
expect(tf.name).to eq("percent")
10011001
expect(tf.virtual?).to be true
10021002
expect do
10031003
tf = TestFraction.new(numerator: 20, denominator: 100)
1004-
expect(tf.percent).to be nil # not whatever is in DATA_DEFAULT column
1004+
expect(tf.percent).to be_nil # not whatever is in DATA_DEFAULT column
10051005
tf.save!
10061006
tf.reload
10071007
end.not_to raise_error
@@ -1014,11 +1014,11 @@ class ::TestFraction < ActiveRecord::Base
10141014
end
10151015
TestFraction.reset_column_information
10161016
tf = TestFraction.columns.detect { |c| c.name == "rem" }
1017-
expect(tf).not_to be nil
1017+
expect(tf).not_to be_nil
10181018
expect(tf.virtual?).to be true
10191019
expect do
10201020
tf = TestFraction.new(numerator: 7, denominator: 5)
1021-
expect(tf.rem).to be nil
1021+
expect(tf.rem).to be_nil
10221022
tf.save!
10231023
tf.reload
10241024
end.not_to raise_error
@@ -1031,13 +1031,13 @@ class ::TestFraction < ActiveRecord::Base
10311031
end
10321032
TestFraction.reset_column_information
10331033
tf = TestFraction.columns.detect { |c| c.name == "expression" }
1034-
expect(tf).not_to be nil
1034+
expect(tf).not_to be_nil
10351035
expect(tf.virtual?).to be true
10361036
expect(tf.type).to be :string
10371037
expect(tf.limit).to be 100
10381038
expect do
10391039
tf = TestFraction.new(numerator: 7, denominator: 5)
1040-
expect(tf.expression).to be nil
1040+
expect(tf.expression).to be_nil
10411041
tf.save!
10421042
tf.reload
10431043
end.not_to raise_error
@@ -1051,14 +1051,14 @@ class ::TestFraction < ActiveRecord::Base
10511051
end
10521052
TestFraction.reset_column_information
10531053
tf = TestFraction.columns.detect { |c| c.name == "percent" }
1054-
expect(tf).not_to be nil
1054+
expect(tf).not_to be_nil
10551055
expect(tf.virtual?).to be true
10561056
expect(tf.type).to be :decimal
10571057
expect(tf.precision).to be 15
10581058
expect(tf.scale).to be 2
10591059
expect do
10601060
tf = TestFraction.new(numerator: 11, denominator: 17)
1061-
expect(tf.percent).to be nil
1061+
expect(tf.percent).to be_nil
10621062
tf.save!
10631063
tf.reload
10641064
end.not_to raise_error
@@ -1071,14 +1071,14 @@ class ::TestFraction < ActiveRecord::Base
10711071
end
10721072
TestFraction.reset_column_information
10731073
tf = TestFraction.columns.detect { |c| c.name == "percent" }
1074-
expect(tf).not_to be nil
1074+
expect(tf).not_to be_nil
10751075
expect(tf.virtual?).to be true
10761076
expect(tf.type).to be :decimal
10771077
expect(tf.precision).to be 12
10781078
expect(tf.scale).to be 5
10791079
expect do
10801080
tf = TestFraction.new(numerator: 11, denominator: 17)
1081-
expect(tf.percent).to be nil
1081+
expect(tf.percent).to be_nil
10821082
tf.save!
10831083
tf.reload
10841084
end.not_to raise_error

spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,12 @@ class ::TestSerializedColumn < ActiveRecord::Base
472472
serialized_column.serialized << new_value
473473
expect(serialized_column.serialized).to eq([new_value])
474474
serialized_column.save
475-
expect(serialized_column.save!).to eq(true)
475+
expect(serialized_column.save!).to be(true)
476476

477477
serialized_column.reload
478478
expect(serialized_column.serialized).to eq([new_value])
479479
serialized_column.serialized = []
480-
expect(serialized_column.save!).to eq(true)
480+
expect(serialized_column.save!).to be(true)
481481
end
482482
end
483483

@@ -516,7 +516,7 @@ class ::TestBinaryColumn < ActiveRecord::Base
516516
binary_column_object = TestBinaryColumn.new
517517
binary_column_object.attachment = binary_value
518518

519-
expect(binary_column_object.save!).to eq(true)
519+
expect(binary_column_object.save!).to be(true)
520520
end
521521
end
522522

@@ -624,8 +624,8 @@ class Group < ActiveRecord::Base
624624
end
625625

626626
it "should test table existence" do
627-
expect(@conn.table_exists?("TEST_POSTS")).to eq true
628-
expect(@conn.table_exists?("NOT_EXISTING")).to eq false
627+
expect(@conn.table_exists?("TEST_POSTS")).to be true
628+
expect(@conn.table_exists?("NOT_EXISTING")).to be false
629629
end
630630

631631
it "should return array from indexes with bind usage" do
@@ -656,7 +656,7 @@ class Group < ActiveRecord::Base
656656
end
657657

658658
it "should return false from temporary_table? with bind usage" do
659-
expect(@conn.temporary_table?("TEST_POSTS")).to eq false
659+
expect(@conn.temporary_table?("TEST_POSTS")).to be false
660660
expect(@logger.logged(:debug).last).to match(/:table_name/)
661661
expect(@logger.logged(:debug).last).to match(/\["table_name", "TEST_POSTS"\]/)
662662
end

spec/active_record/oracle_enhanced/type/boolean_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ class ::Test3Employee < ActiveRecord::Base
151151
expect(@employee3.test_boolean_before_type_cast).to eq("N")
152152
create_employee3(test_boolean: nil)
153153
expect(@employee3.test_boolean.class).to eq(NilClass)
154-
expect(@employee3.test_boolean_before_type_cast).to eq(nil)
154+
expect(@employee3.test_boolean_before_type_cast).to be_nil
155155
create_employee3(test_boolean: "")
156156
expect(@employee3.test_boolean.class).to eq(NilClass)
157-
expect(@employee3.test_boolean_before_type_cast).to eq(nil)
157+
expect(@employee3.test_boolean_before_type_cast).to be_nil
158158
end
159159

160160
it "should return string value from VARCHAR2 column with boolean column name but attribute is set to :string" do

spec/active_record/oracle_enhanced/type/national_character_text_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ::TestSerializeEmployee < ActiveRecord::Base
7979
@employee.reload
8080
expect(@employee.comments).to eq(@nclob_data)
8181
@employee.comments = @nclob_data2
82-
expect(@employee.save).to eq(true)
82+
expect(@employee.save).to be(true)
8383
@employee.reload
8484
expect(@employee.comments).to eq(@nclob_data)
8585
end
@@ -90,12 +90,12 @@ class ::TestSerializeEmployee < ActiveRecord::Base
9090
comments: nil
9191
)
9292
expect(@employee.comments).to be_nil
93-
expect(@employee.save).to eq(true)
93+
expect(@employee.save).to be(true)
9494
expect(@employee).to be_valid
9595
@employee.reload
9696
expect(@employee.comments).to be_nil
9797
@employee.comments = {}
98-
expect(@employee.save).to eq(true)
98+
expect(@employee.save).to be(true)
9999
@employee.reload
100100
# should not set readonly
101101
expect(@employee.comments).to be_nil

spec/active_record/oracle_enhanced/type/text_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ::TestSerializeEmployee < ActiveRecord::Base
7878
@employee.reload
7979
expect(@employee.comments).to eq("initial")
8080
@employee.comments = "changed"
81-
expect(@employee.save).to eq(true)
81+
expect(@employee.save).to be(true)
8282
@employee.reload
8383
expect(@employee.comments).to eq("initial")
8484
end
@@ -89,12 +89,12 @@ class ::TestSerializeEmployee < ActiveRecord::Base
8989
comments: nil
9090
)
9191
expect(@employee.comments).to be_nil
92-
expect(@employee.save).to eq(true)
92+
expect(@employee.save).to be(true)
9393
expect(@employee).to be_valid
9494
@employee.reload
9595
expect(@employee.comments).to be_nil
9696
@employee.comments = {}
97-
expect(@employee.save).to eq(true)
97+
expect(@employee.save).to be(true)
9898
@employee.reload
9999
# should not set readonly
100100
expect(@employee.comments).to be_nil

0 commit comments

Comments
 (0)