diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-01-05 17:59:36 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-01-05 18:04:52 +0100 |
commit | 947e1d5e85fa87128b7c5e21da55b92826cd7801 (patch) | |
tree | 5d86ab00506c39d154226f177cce36245d2fd440 /activesupport/test | |
parent | fada87e916dd50eb6766cac919de41f0be2a12bc (diff) | |
download | rails-947e1d5e85fa87128b7c5e21da55b92826cd7801.tar.gz rails-947e1d5e85fa87128b7c5e21da55b92826cd7801.tar.bz2 rails-947e1d5e85fa87128b7c5e21da55b92826cd7801.zip |
deprecate `assert_blank` and `assert_present`.
They don't add any benefits over `assert object.blank?`
and `assert object.present?`
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/caching_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/deprecation_test.rb | 7 | ||||
-rw-r--r-- | activesupport/test/test_test.rb | 36 |
3 files changed, 29 insertions, 20 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index a2e2c51283..5158bbc196 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -675,7 +675,7 @@ class FileStoreTest < ActiveSupport::TestCase def test_log_exception_when_cache_read_fails File.expects(:exist?).raises(StandardError, "failed") @cache.send(:read_entry, "winston", {}) - assert_present @buffer.string + assert @buffer.string.present? end end @@ -897,12 +897,12 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase def test_logging @cache.fetch('foo') { 'bar' } - assert_present @buffer.string + assert @buffer.string.present? end def test_mute_logging @cache.mute { @cache.fetch('foo') { 'bar' } } - assert_blank @buffer.string + assert @buffer.string.blank? end end diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index 332100f5a1..c1a468ec86 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -119,9 +119,10 @@ class DeprecationTest < ActiveSupport::TestCase ActiveSupport::Deprecation.behavior = :silence behavior = ActiveSupport::Deprecation.behavior.first - assert_blank capture(:stderr) { + stderr_output = capture(:stderr) { assert_nil behavior.call('Some error!', ['call stack!']) } + assert stderr_output.blank? end def test_deprecated_instance_variable_proxy @@ -254,10 +255,10 @@ class DeprecationTest < ActiveSupport::TestCase klass::OLD.to_s end end - + def test_deprecated_instance_variable_with_instance_deprecator deprecator = deprecator_with_messages - + klass = Class.new() do def initialize(deprecator) @request = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator) diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb index 0f93c8b59e..3e6ac811a4 100644 --- a/activesupport/test/test_test.rb +++ b/activesupport/test/test_test.rb @@ -92,17 +92,21 @@ class AssertBlankTest < ActiveSupport::TestCase NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] def test_assert_blank_true - BLANK.each { |v| assert_blank v } + BLANK.each { |value| + assert_deprecated { assert_blank value } + } end def test_assert_blank_false NOT_BLANK.each { |v| - begin - assert_blank v - fail 'should not get to here' - rescue Exception => e - assert_match(/is not blank/, e.message) - end + assert_deprecated { + begin + assert_blank v + fail 'should not get to here' + rescue Exception => e + assert_match(/is not blank/, e.message) + end + } } end end @@ -112,17 +116,21 @@ class AssertPresentTest < ActiveSupport::TestCase NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] def test_assert_present_true - NOT_BLANK.each { |v| assert_present v } + NOT_BLANK.each { |v| + assert_deprecated { assert_present v } + } end def test_assert_present_false BLANK.each { |v| - begin - assert_present v - fail 'should not get to here' - rescue Exception => e - assert_match(/is blank/, e.message) - end + assert_deprecated { + begin + assert_present v + fail 'should not get to here' + rescue Exception => e + assert_match(/is blank/, e.message) + end + } } end end |