Skip to content

Commit fdfebb7

Browse files
spastorinojosevalim
authored andcommitted
Make use of assert_equal to test equallity between object assert expects and object and a message of error
[rails#4611 state:committed] Signed-off-by: José Valim <[email protected]>
1 parent d7a3e65 commit fdfebb7

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

activemodel/test/cases/validations/validates_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_validates_with_if_as_shared_conditions
4545
Person.validates :karma, :presence => true, :email => true, :if => :condition_is_true
4646
person = Person.new
4747
person.valid?
48-
assert ["can't be blank", "is not an email"], person.errors[:karma].sort
48+
assert_equal ["can't be blank", "is not an email"], person.errors[:karma].sort
4949
end
5050

5151
def test_validates_with_unless_shared_conditions
@@ -111,4 +111,4 @@ def test_validates_with_included_validator_and_options
111111
person.valid?
112112
assert_equal ['Local validator please'], person.errors[:title]
113113
end
114-
end
114+
end

activemodel/test/cases/validations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_validation_with_message_as_proc
228228

229229
t = Topic.new
230230
assert t.invalid?
231-
assert ["NO BLANKS HERE"], t.errors[:title]
231+
assert_equal ["NO BLANKS HERE"], t.errors[:title]
232232
end
233233

234234
def test_list_of_validators_for_model

activerecord/test/cases/associations/join_model_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_has_many_class_methods_called_by_method_missing
289289
end
290290

291291
def test_has_many_array_methods_called_by_method_missing
292-
assert true, authors(:david).categories.any? { |category| category.name == 'General' }
292+
assert authors(:david).categories.any? { |category| category.name == 'General' }
293293
assert_nothing_raised { authors(:david).categories.sort }
294294
end
295295

activerecord/test/cases/autosave_association_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def test_should_still_work_without_an_associated_model
765765
@ship.destroy
766766
@pirate.reload.catchphrase = "Arr"
767767
@pirate.save
768-
assert 'Arr', @pirate.reload.catchphrase
768+
assert_equal 'Arr', @pirate.reload.catchphrase
769769
end
770770

771771
def test_should_automatically_save_the_associated_model
@@ -885,7 +885,7 @@ def test_should_still_work_without_an_associated_model
885885
@pirate.destroy
886886
@ship.reload.name = "The Vile Insanity"
887887
@ship.save
888-
assert 'The Vile Insanity', @ship.reload.name
888+
assert_equal 'The Vile Insanity', @ship.reload.name
889889
end
890890

891891
def test_should_automatically_save_the_associated_model

activerecord/test/cases/finder_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,10 @@ def test_find_all_by_two_attributes_with_one_being_an_aggregate
722722

723723
def test_find_all_by_one_attribute_with_options
724724
topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC")
725-
assert topics(:first), topics.last
725+
assert_equal topics(:first), topics.last
726726

727727
topics = Topic.find_all_by_content("Have a nice day", :order => "id")
728-
assert topics(:first), topics.first
728+
assert_equal topics(:first), topics.first
729729
end
730730

731731
def test_find_all_by_array_attribute

activesupport/test/buffered_logger_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_should_not_mutate_message
7373
end
7474

7575
@logger.flush
76-
assert !@output.string.empty?, @logger.send(:buffer).size
76+
assert !@output.string.empty?, @logger.send(:buffer).size.to_s
7777
end
7878

7979
define_method "test_disabling_auto_flush_with_#{disable.inspect}_should_flush_at_max_buffer_size_as_failsafe" do
@@ -86,7 +86,7 @@ def test_should_not_mutate_message
8686
end
8787

8888
@logger.info 'there it is.'
89-
assert !@output.string.empty?, @logger.send(:buffer).size
89+
assert !@output.string.empty?, @logger.send(:buffer).size.to_s
9090
end
9191
end
9292

activesupport/test/caching_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def test_local_cache_of_read
375375

376376
def test_local_cache_of_write_nil
377377
@cache.with_local_cache do
378-
assert true, @cache.write('foo', nil)
378+
assert @cache.write('foo', nil)
379379
assert_nil @cache.read('foo')
380380
@peek.write('foo', 'bar')
381381
assert_nil @cache.read('foo')
@@ -394,7 +394,7 @@ def test_local_cache_of_exist
394394
@cache.with_local_cache do
395395
@cache.write('foo', 'bar')
396396
@peek.delete('foo')
397-
assert true, @cache.exist?('foo')
397+
assert @cache.exist?('foo')
398398
end
399399
end
400400

0 commit comments

Comments
 (0)