From 48f548fd4507185d7f339f42b3a90f09c5fd9eb7 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 16 May 2010 01:33:58 -0300 Subject: [PATCH] Make use of assert_equal to test equallity between object assert expects and object and a message of error [#4611 state:committed] --- actionpack/test/controller/assert_select_test.rb | 4 ++-- actionpack/test/controller/render_test.rb | 4 ++-- actionpack/test/template/capture_helper_test.rb | 2 +- .../test/cases/validations/validates_test.rb | 4 ++-- activemodel/test/cases/validations_test.rb | 2 +- .../test/cases/associations/join_model_test.rb | 2 +- .../test/cases/autosave_association_test.rb | 4 ++-- activerecord/test/cases/finder_test.rb | 4 ++-- activesupport/test/buffered_logger_test.rb | 4 ++-- activesupport/test/caching_test.rb | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index f1254ab..3fe20f9 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -276,8 +276,8 @@ class AssertSelectTest < ActionController::TestCase def test_css_select render_html %Q{
} - assert 2, css_select("div").size - assert 0, css_select("p").size + assert_equal 2, css_select("div").size + assert_equal 0, css_select("p").size end def test_nested_css_select diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 180d5e1..52049f2 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1388,7 +1388,7 @@ class EtagRenderTest < ActionController::TestCase def test_render_against_etag_request_should_have_no_content_length_when_match @request.if_none_match = etag_for("hello david") get :render_hello_world_from_variable - assert !@response.headers.has_key?("Content-Length"), @response.headers['Content-Length'] + assert !@response.headers.has_key?("Content-Length") end def test_render_against_etag_request_should_200_when_no_match @@ -1524,4 +1524,4 @@ class LastModifiedRenderTest < ActionController::TestCase get :conditional_hello_with_bangs assert_response :success end -end \ No newline at end of file +end diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index bf541c1..9f3d68a 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -74,7 +74,7 @@ class CaptureHelperTest < ActionView::TestCase @av.output_buffer.force_encoding(alt_encoding) @av.with_output_buffer do - assert alt_encoding, @av.output_buffer.encoding + assert_equal alt_encoding, @av.output_buffer.encoding end end end diff --git a/activemodel/test/cases/validations/validates_test.rb b/activemodel/test/cases/validations/validates_test.rb index d15fb4a..b85e491 100644 --- a/activemodel/test/cases/validations/validates_test.rb +++ b/activemodel/test/cases/validations/validates_test.rb @@ -45,7 +45,7 @@ class ValidatesTest < ActiveModel::TestCase Person.validates :karma, :presence => true, :email => true, :if => :condition_is_true person = Person.new person.valid? - assert ["can't be blank", "is not an email"], person.errors[:karma].sort + assert_equal ["can't be blank", "is not an email"], person.errors[:karma].sort end def test_validates_with_unless_shared_conditions @@ -111,4 +111,4 @@ class ValidatesTest < ActiveModel::TestCase person.valid? assert_equal ['Local validator please'], person.errors[:title] end -end \ No newline at end of file +end diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index aa75b8b..af195af 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -228,7 +228,7 @@ class ValidationsTest < ActiveModel::TestCase t = Topic.new assert t.invalid? - assert ["NO BLANKS HERE"], t.errors[:title] + assert_equal ["NO BLANKS HERE"], t.errors[:title] end def test_list_of_validators_for_model diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index 8bdf8bc..dca72be 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -289,7 +289,7 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase end def test_has_many_array_methods_called_by_method_missing - assert true, authors(:david).categories.any? { |category| category.name == 'General' } + assert authors(:david).categories.any? { |category| category.name == 'General' } assert_nothing_raised { authors(:david).categories.sort } end diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 2995cc6..5cc5dff 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -765,7 +765,7 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase @ship.destroy @pirate.reload.catchphrase = "Arr" @pirate.save - assert 'Arr', @pirate.reload.catchphrase + assert_equal 'Arr', @pirate.reload.catchphrase end def test_should_automatically_save_the_associated_model @@ -885,7 +885,7 @@ class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase @pirate.destroy @ship.reload.name = "The Vile Insanity" @ship.save - assert 'The Vile Insanity', @ship.reload.name + assert_equal 'The Vile Insanity', @ship.reload.name end def test_should_automatically_save_the_associated_model diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index e78db89..c73ad50 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -722,10 +722,10 @@ class FinderTest < ActiveRecord::TestCase def test_find_all_by_one_attribute_with_options topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC") - assert topics(:first), topics.last + assert_equal topics(:first), topics.last topics = Topic.find_all_by_content("Have a nice day", :order => "id") - assert topics(:first), topics.first + assert_equal topics(:first), topics.first end def test_find_all_by_array_attribute diff --git a/activesupport/test/buffered_logger_test.rb b/activesupport/test/buffered_logger_test.rb index 7a0ec2e..5b072d4 100644 --- a/activesupport/test/buffered_logger_test.rb +++ b/activesupport/test/buffered_logger_test.rb @@ -73,7 +73,7 @@ class BufferedLoggerTest < Test::Unit::TestCase end @logger.flush - assert !@output.string.empty?, @logger.send(:buffer).size + assert !@output.string.empty?, @logger.send(:buffer).size.to_s end define_method "test_disabling_auto_flush_with_#{disable.inspect}_should_flush_at_max_buffer_size_as_failsafe" do @@ -86,7 +86,7 @@ class BufferedLoggerTest < Test::Unit::TestCase end @logger.info 'there it is.' - assert !@output.string.empty?, @logger.send(:buffer).size + assert !@output.string.empty?, @logger.send(:buffer).size.to_s end end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index d9ff120..3e14c75 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -375,7 +375,7 @@ module LocalCacheBehavior def test_local_cache_of_write_nil @cache.with_local_cache do - assert true, @cache.write('foo', nil) + assert @cache.write('foo', nil) assert_nil @cache.read('foo') @peek.write('foo', 'bar') assert_nil @cache.read('foo') @@ -394,7 +394,7 @@ module LocalCacheBehavior @cache.with_local_cache do @cache.write('foo', 'bar') @peek.delete('foo') - assert true, @cache.exist?('foo') + assert @cache.exist?('foo') end end -- 1.7.1