Merge pull request #44442 from nvasilevski/fix-some-assertionless-tests
[Active Support] Add explicit assertions to tests with no assertions
This commit is contained in:
commit
e7547876da
|
@ -28,7 +28,7 @@ module ActiveSupport
|
||||||
|
|
||||||
object.stub(method_name, mock, &block)
|
object.stub(method_name, mock, &block)
|
||||||
|
|
||||||
mock.verify
|
assert_mock(mock)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_not_called(object, method_name, message = nil, &block)
|
def assert_not_called(object, method_name, message = nil, &block)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class FileStoreTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_clear_without_cache_dir
|
def test_clear_without_cache_dir
|
||||||
FileUtils.rm_r(cache_dir)
|
FileUtils.rm_r(cache_dir)
|
||||||
@cache.clear
|
assert_nothing_raised { @cache.clear }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_long_uri_encoded_keys
|
def test_long_uri_encoded_keys
|
||||||
|
|
|
@ -10,11 +10,15 @@ class NullStoreTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_clear
|
def test_clear
|
||||||
|
@cache.write("name", "value")
|
||||||
@cache.clear
|
@cache.clear
|
||||||
|
assert_nil @cache.read("name")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cleanup
|
def test_cleanup
|
||||||
|
@cache.write("name", "value")
|
||||||
@cache.cleanup
|
@cache.cleanup
|
||||||
|
assert_nil @cache.read("name")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_write
|
def test_write
|
||||||
|
@ -44,6 +48,7 @@ class NullStoreTest < ActiveSupport::TestCase
|
||||||
def test_delete_matched
|
def test_delete_matched
|
||||||
@cache.write("name", "value")
|
@cache.write("name", "value")
|
||||||
@cache.delete_matched(/name/)
|
@cache.delete_matched(/name/)
|
||||||
|
assert_nil @cache.read("name")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_local_store_strategy
|
def test_local_store_strategy
|
||||||
|
|
|
@ -45,9 +45,11 @@ class KernelSuppressTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_suppression
|
def test_suppression
|
||||||
suppress(ArgumentError) { raise ArgumentError }
|
assert_nothing_raised do
|
||||||
suppress(LoadError) { raise LoadError }
|
suppress(ArgumentError) { raise ArgumentError }
|
||||||
suppress(LoadError, ArgumentError) { raise LoadError }
|
suppress(LoadError) { raise LoadError }
|
||||||
suppress(LoadError, ArgumentError) { raise ArgumentError }
|
suppress(LoadError, ArgumentError) { raise LoadError }
|
||||||
|
suppress(LoadError, ArgumentError) { raise ArgumentError }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -508,8 +508,10 @@ class DeprecationTest < ActiveSupport::TestCase
|
||||||
def test_no_disallowed_behavior_with_no_disallowed_messages
|
def test_no_disallowed_behavior_with_no_disallowed_messages
|
||||||
resetting_disallowed_deprecation_config do
|
resetting_disallowed_deprecation_config do
|
||||||
ActiveSupport::Deprecation.disallowed_behavior = :raise
|
ActiveSupport::Deprecation.disallowed_behavior = :raise
|
||||||
@dtc.none
|
assert_nothing_raised do
|
||||||
@dtc.partially
|
@dtc.none
|
||||||
|
@dtc.partially
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -518,7 +520,7 @@ class DeprecationTest < ActiveSupport::TestCase
|
||||||
ActiveSupport::Deprecation.disallowed_behavior = :raise
|
ActiveSupport::Deprecation.disallowed_behavior = :raise
|
||||||
ActiveSupport::Deprecation.disallowed_warnings = ["foo=nil"]
|
ActiveSupport::Deprecation.disallowed_warnings = ["foo=nil"]
|
||||||
|
|
||||||
@dtc.none
|
assert_nothing_raised { @dtc.none }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,11 @@ class SyncLogSubscriberTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_does_not_send_the_event_if_it_doesnt_match_the_class
|
def test_does_not_send_the_event_if_it_doesnt_match_the_class
|
||||||
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
|
assert_nothing_raised do
|
||||||
instrument "unknown_event.my_log_subscriber"
|
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
|
||||||
wait
|
instrument "unknown_event.my_log_subscriber"
|
||||||
# If we get here, it means that NoMethodError was not raised.
|
wait
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_does_not_send_the_event_if_logger_is_nil
|
def test_does_not_send_the_event_if_logger_is_nil
|
||||||
|
@ -108,9 +109,11 @@ class SyncLogSubscriberTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_does_not_fail_with_non_namespaced_events
|
def test_does_not_fail_with_non_namespaced_events
|
||||||
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
|
assert_nothing_raised do
|
||||||
instrument "whatever"
|
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
|
||||||
wait
|
instrument "whatever"
|
||||||
|
wait
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_flushes_loggers
|
def test_flushes_loggers
|
||||||
|
|
|
@ -43,7 +43,9 @@ class LoggerTest < ActiveSupport::TestCase
|
||||||
str = +"\x80"
|
str = +"\x80"
|
||||||
str.force_encoding("ASCII-8BIT")
|
str.force_encoding("ASCII-8BIT")
|
||||||
|
|
||||||
logger.add Logger::DEBUG, str
|
assert_nothing_raised do
|
||||||
|
logger.add Logger::DEBUG, str
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
logger.close
|
logger.close
|
||||||
t.close true
|
t.close true
|
||||||
|
@ -61,7 +63,9 @@ class LoggerTest < ActiveSupport::TestCase
|
||||||
str = +"\x80"
|
str = +"\x80"
|
||||||
str.force_encoding("ASCII-8BIT")
|
str.force_encoding("ASCII-8BIT")
|
||||||
|
|
||||||
logger.add Logger::DEBUG, str
|
assert_nothing_raised do
|
||||||
|
logger.add Logger::DEBUG, str
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
logger.close
|
logger.close
|
||||||
File.unlink fname
|
File.unlink fname
|
||||||
|
|
|
@ -14,10 +14,10 @@ module SharedMessageMetadataTests
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_verifies_array_when_purpose_matches
|
def test_verifies_array_when_purpose_matches
|
||||||
unless null_serializing?
|
skip if null_serializing?
|
||||||
data = [ "credit_card_no: 5012-6748-9087-5678", { "card_holder" => "Donald", "issued_on" => Time.local(2017) }, 12345 ]
|
|
||||||
assert_equal data, parse(generate(data, purpose: :registration), purpose: :registration)
|
data = [ "credit_card_no: 5012-6748-9087-5678", { "card_holder" => "Donald", "issued_on" => Time.local(2017) }, 12345 ]
|
||||||
end
|
assert_equal data, parse(generate(data, purpose: :registration), purpose: :registration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encryption_and_decryption_with_different_purposes_returns_nil
|
def test_encryption_and_decryption_with_different_purposes_returns_nil
|
||||||
|
|
|
@ -185,8 +185,10 @@ module Notifications
|
||||||
|
|
||||||
ActiveSupport::Notifications.subscribe("foo", TestSubscriber.new)
|
ActiveSupport::Notifications.subscribe("foo", TestSubscriber.new)
|
||||||
|
|
||||||
ActiveSupport::Notifications.instrument("foo") do
|
assert_nothing_raised do
|
||||||
ActiveSupport::Notifications.subscribe("foo") { }
|
ActiveSupport::Notifications.instrument("foo") do
|
||||||
|
ActiveSupport::Notifications.subscribe("foo") { }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
ActiveSupport::Notifications.notifier = old_notifier
|
ActiveSupport::Notifications.notifier = old_notifier
|
||||||
|
|
Loading…
Reference in New Issue