aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/test/controller/output_escaping_test.rb2
-rw-r--r--actionpack/test/controller/render_test.rb12
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb2
-rw-r--r--actionpack/test/controller/test_test.rb2
-rw-r--r--actionpack/test/controller/webservice_test.rb4
-rw-r--r--actionpack/test/template/atom_feed_helper_test.rb2
-rw-r--r--activemodel/test/cases/mass_assignment_security_test.rb6
-rw-r--r--activerecord/test/cases/aggregations_test.rb2
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb4
-rw-r--r--activerecord/test/cases/method_scoping_test.rb2
-rw-r--r--activerecord/test/cases/named_scope_test.rb4
-rw-r--r--activerecord/test/cases/primary_keys_test.rb2
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb4
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb10
-rw-r--r--activesupport/test/caching_test.rb4
19 files changed, 37 insertions, 35 deletions
diff --git a/actionpack/test/controller/output_escaping_test.rb b/actionpack/test/controller/output_escaping_test.rb
index 43a8c05cda..f6913a2138 100644
--- a/actionpack/test/controller/output_escaping_test.rb
+++ b/actionpack/test/controller/output_escaping_test.rb
@@ -3,7 +3,7 @@ require 'abstract_unit'
class OutputEscapingTest < ActiveSupport::TestCase
test "escape_html shouldn't die when passed nil" do
- assert ERB::Util.h(nil).blank?
+ assert_blank ERB::Util.h(nil)
end
test "escapeHTML should escape strings" do
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 258f511f10..9037a13343 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1113,7 +1113,7 @@ class RenderTest < ActionController::TestCase
def test_head_with_location_header
get :head_with_location_header
- assert @response.body.blank?
+ assert_blank @response.body
assert_equal "/foo", @response.headers["Location"]
assert_response :ok
end
@@ -1126,7 +1126,7 @@ class RenderTest < ActionController::TestCase
end
get :head_with_location_object
- assert @response.body.blank?
+ assert_blank @response.body
assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
assert_response :ok
end
@@ -1134,7 +1134,7 @@ class RenderTest < ActionController::TestCase
def test_head_with_custom_header
get :head_with_custom_header
- assert @response.body.blank?
+ assert_blank @response.body
assert_equal "something", @response.headers["X-Custom-Header"]
assert_response :ok
end
@@ -1414,7 +1414,7 @@ class EtagRenderTest < ActionController::TestCase
assert_equal 200, @response.status.to_i
assert_not_nil @response.last_modified
assert_nil @response.etag
- assert @response.body.present?
+ assert_present @response.body
end
def test_render_with_etag
@@ -1499,7 +1499,7 @@ class LastModifiedRenderTest < ActionController::TestCase
@request.if_modified_since = @last_modified
get :conditional_hello
assert_equal 304, @response.status.to_i
- assert @response.body.blank?, @response.body
+ assert_blank @response.body
assert_equal @last_modified, @response.headers['Last-Modified']
end
@@ -1514,7 +1514,7 @@ class LastModifiedRenderTest < ActionController::TestCase
@request.if_modified_since = 'Thu, 16 Jul 2008 00:00:00 GMT'
get :conditional_hello
assert_equal 200, @response.status.to_i
- assert !@response.body.blank?
+ assert_present @response.body
assert_equal @last_modified, @response.headers['Last-Modified']
end
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index be05ef6167..5ec760d4ea 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -251,7 +251,7 @@ class FreeCookieControllerTest < ActionController::TestCase
test 'should not emit a csrf-token meta tag' do
get :meta
- assert @response.body.blank?
+ assert_blank @response.body
end
end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 7e7e4bd463..de2cab3e79 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -546,7 +546,7 @@ XML
assert_equal "bar", @request.params[:foo]
@request.recycle!
post :no_op
- assert @request.params[:foo].blank?
+ assert_blank @request.params[:foo]
end
def test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb
index 5942950b15..2e6cf48406 100644
--- a/actionpack/test/controller/webservice_test.rb
+++ b/actionpack/test/controller/webservice_test.rb
@@ -29,7 +29,7 @@ class WebServiceTest < ActionController::IntegrationTest
def test_check_parameters
with_test_route_set do
get "/"
- assert @controller.response.body.blank?
+ assert_blank @controller.response.body
end
end
@@ -161,7 +161,7 @@ class WebServiceTest < ActionController::IntegrationTest
def test_use_xml_ximple_with_empty_request
with_test_route_set do
assert_nothing_raised { post "/", "", {'CONTENT_TYPE' => 'application/xml'} }
- assert @controller.response.body.blank?
+ assert_blank @controller.response.body
end
end
diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb
index 869ea22469..fb43a8f960 100644
--- a/actionpack/test/template/atom_feed_helper_test.rb
+++ b/actionpack/test/template/atom_feed_helper_test.rb
@@ -226,7 +226,7 @@ class AtomFeedTest < ActionController::TestCase
get :index, :id=>"provide_builder"
# because we pass in the non-default builder, the content generated by the
# helper should go 'nowhere'. Leaving the response body blank.
- assert @response.body.blank?
+ assert_blank @response.body
end
end
diff --git a/activemodel/test/cases/mass_assignment_security_test.rb b/activemodel/test/cases/mass_assignment_security_test.rb
index c25b0fdf00..f84e55e8d9 100644
--- a/activemodel/test/cases/mass_assignment_security_test.rb
+++ b/activemodel/test/cases/mass_assignment_security_test.rb
@@ -25,13 +25,13 @@ class MassAssignmentSecurityTest < ActiveModel::TestCase
end
def test_mass_assignment_protection_inheritance
- assert LoosePerson.accessible_attributes.blank?
+ assert_blank LoosePerson.accessible_attributes
assert_equal Set.new([ 'credit_rating', 'administrator']), LoosePerson.protected_attributes
- assert LooseDescendant.accessible_attributes.blank?
+ assert_blank LooseDescendant.accessible_attributes
assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number']), LooseDescendant.protected_attributes
- assert LooseDescendantSecond.accessible_attributes.blank?
+ assert_blank LooseDescendantSecond.accessible_attributes
assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number', 'name']), LooseDescendantSecond.protected_attributes,
'Running attr_protected twice in one class should merge the protections'
diff --git a/activerecord/test/cases/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb
index 9e285e57dc..3e0e6dce2c 100644
--- a/activerecord/test/cases/aggregations_test.rb
+++ b/activerecord/test/cases/aggregations_test.rb
@@ -99,7 +99,7 @@ class AggregationsTest < ActiveRecord::TestCase
customers(:zaphod).save
customers(:zaphod).reload
assert_kind_of Address, customers(:zaphod).address
- assert customers(:zaphod).address.street.nil?
+ assert_nil customers(:zaphod).address.street
end
def test_nil_assignment_results_in_nil
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index a1ce9b1689..28234ebe49 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -22,7 +22,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
def test_belongs_to
Client.find(3).firm.name
assert_equal companies(:first_firm).name, Client.find(3).firm.name
- assert !Client.find(3).firm.nil?, "Microsoft should have a firm"
+ assert_not_nil Client.find(3).firm, "Microsoft should have a firm"
end
def test_belongs_to_with_primary_key
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index ac2021c369..7e10a8ceeb 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -633,7 +633,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
# Should not be destroyed since the association is not dependent.
assert_nothing_raised do
- assert Client.find(client_id).firm.nil?
+ assert_nil Client.find(client_id).firm
end
end
@@ -658,7 +658,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [client_id], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is dependent.
- assert Client.find_by_id(client_id).nil?
+ assert_nil Client.find_by_id(client_id)
end
def test_clearing_an_exclusively_dependent_association_collection
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 469a21b9bf..e959ed46cc 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -253,7 +253,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
def test_dependence_with_missing_association_and_nullify
Account.destroy_all
firm = DependentFirm.find(:first)
- assert firm.account.nil?
+ assert_nil firm.account
firm.destroy
end
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index fcdb81e92e..b83966e91c 100644
--- a/activerecord/test/cases/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -427,8 +427,8 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
def test_has_many_through_uses_conditions_specified_on_the_has_many_association
author = Author.find(:first)
- assert !author.comments.blank?
- assert author.nonexistant_comments.blank?
+ assert_present author.comments
+ assert_blank author.nonexistant_comments
end
def test_has_many_through_uses_correct_attributes
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 5256ab8d11..312628a3e3 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -449,7 +449,7 @@ class NestedScopingTest < ActiveRecord::TestCase
Comment.send(:with_scope, :create => { :body => "Hey guys, nested scopes are broken. Please fix!" }) do
Comment.send(:with_exclusive_scope, :create => { :post_id => 1 }) do
assert_equal({:post_id => 1}, Comment.scoped.send(:scope_for_create))
- assert Comment.new.body.blank?
+ assert_blank Comment.new.body
comment = Comment.create :body => "Hey guys"
end
end
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index c42dda2ccb..3d6975d0b5 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -480,8 +480,8 @@ class DynamicScopeTest < ActiveRecord::TestCase
end
def test_dynamic_scope_should_create_methods_after_hitting_method_missing
- assert Developer.methods.grep(/scoped_by_created_at/).blank?
+ assert_blank Developer.methods.grep(/scoped_by_created_at/)
Developer.scoped_by_created_at(nil)
- assert Developer.methods.grep(/scoped_by_created_at/).present?
+ assert_present Developer.methods.grep(/scoped_by_created_at/)
end
end
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 1e44237e0a..63d8c7d1c1 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -11,7 +11,7 @@ class PrimaryKeysTest < ActiveRecord::TestCase
def test_to_key_with_default_primary_key
topic = Topic.new
- assert topic.to_key.nil?
+ assert_nil topic.to_key
topic = Topic.find(1)
assert_equal [1], topic.to_key
end
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 9494990b04..d56e5a7999 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -209,7 +209,7 @@ class NestedRelationScopingTest < ActiveRecord::TestCase
def test_nested_exclusive_scope_for_create
comment = Comment.create_with(:body => "Hey guys, nested scopes are broken. Please fix!").scoping do
Comment.unscoped.create_with(:post_id => 1).scoping do
- assert Comment.new.body.blank?
+ assert_blank Comment.new.body
Comment.create :body => "Hey guys"
end
end
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index bd6e216c62..aa75aa27d4 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -411,7 +411,7 @@ class RelationTest < ActiveRecord::TestCase
def test_find_in_empty_array
authors = Author.scoped.where(:id => [])
- assert authors.all.blank?
+ assert_blank authors.all
end
def test_exists
@@ -486,7 +486,7 @@ class RelationTest < ActiveRecord::TestCase
def test_relation_merging_with_locks
devs = Developer.lock.where("salary >= 80000").order("id DESC") & Developer.limit(2)
- assert devs.locked.present?
+ assert_present devs.locked
end
def test_relation_merging_with_preload
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index 8c68f42781..a4e0361a32 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -67,15 +67,17 @@ module ActiveSupport
# Test if an expression is blank. Passes if object.blank? is true.
#
# assert_blank [] # => true
- def assert_blank(object)
- assert object.blank?, "#{object.inspect} is not blank"
+ def assert_blank(object, message=nil)
+ message ||= "#{object.inspect} is not blank"
+ assert object.blank?, message
end
# Test if an expression is not blank. Passes if object.present? is true.
#
# assert_present {:data => 'x' } # => true
- def assert_present(object)
- assert object.present?, "#{object.inspect} is blank"
+ def assert_present(object, message=nil)
+ message ||= "#{object.inspect} is blank"
+ assert object.present?, message
end
end
end
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index b79a7bbaec..28ef695a4b 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -649,12 +649,12 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase
def test_logging
@cache.fetch('foo') { 'bar' }
- assert @buffer.string.present?
+ assert_present @buffer.string
end
def test_mute_logging
@cache.mute { @cache.fetch('foo') { 'bar' } }
- assert @buffer.string.blank?
+ assert_blank @buffer.string
end
end