Skip to content

Commit

Permalink
Remove assert_nothing_raised.
Browse files Browse the repository at this point in the history
See discussion in minitest/minitest#159.
  • Loading branch information
tgxworld committed Mar 23, 2015
1 parent 4a0f314 commit 718eac6
Show file tree
Hide file tree
Showing 125 changed files with 715 additions and 1,175 deletions.
6 changes: 3 additions & 3 deletions actionmailer/test/base_test.rb
Expand Up @@ -26,7 +26,7 @@ class BaseTest < ActiveSupport::TestCase
end

test "method call to mail does not raise error" do
assert_nothing_raised { BaseMailer.welcome }
BaseMailer.welcome
end

# Basic mail usage without block
Expand Down Expand Up @@ -268,7 +268,7 @@ def on_render
end

mail = LateInlineAttachmentMailer.on_render
assert_nothing_raised { mail.message }
mail.message

assert_equal ["image/jpeg; filename=controller_attachments.jpg",
"image/jpeg; filename=attachments.jpg"], mail.attachments.inline.map {|a| a['Content-Type'].to_s }
Expand All @@ -286,7 +286,7 @@ def welcome
end
end

assert_nothing_raised { LateAttachmentAccessorMailer.welcome.message }
LateAttachmentAccessorMailer.welcome.message
end

# Implicit multipart
Expand Down
4 changes: 1 addition & 3 deletions actionmailer/test/delivery_methods_test.rb
Expand Up @@ -215,9 +215,7 @@ def welcome(hash={})
begin
DeliveryMailer.delivery_method = BogusDelivery
DeliveryMailer.raise_delivery_errors = false
assert_nothing_raised do
DeliveryMailer.welcome.deliver_now
end
DeliveryMailer.welcome.deliver_now
ensure
DeliveryMailer.raise_delivery_errors = old_raise_delivery_errors
end
Expand Down
54 changes: 19 additions & 35 deletions actionmailer/test/test_helper_test.rb
Expand Up @@ -48,46 +48,34 @@ def test_read_fixture
end

def test_assert_emails
assert_nothing_raised do
assert_emails 1 do
TestHelperMailer.test.deliver_now
end
assert_emails 1 do
TestHelperMailer.test.deliver_now
end
end

def test_repeated_assert_emails_calls
assert_nothing_raised do
assert_emails 1 do
TestHelperMailer.test.deliver_now
end
assert_emails 1 do
TestHelperMailer.test.deliver_now
end

assert_nothing_raised do
assert_emails 2 do
TestHelperMailer.test.deliver_now
TestHelperMailer.test.deliver_now
end
assert_emails 2 do
TestHelperMailer.test.deliver_now
TestHelperMailer.test.deliver_now
end
end

def test_assert_emails_with_no_block
assert_nothing_raised do
TestHelperMailer.test.deliver_now
assert_emails 1
end
TestHelperMailer.test.deliver_now
assert_emails 1

assert_nothing_raised do
TestHelperMailer.test.deliver_now
TestHelperMailer.test.deliver_now
assert_emails 3
end
TestHelperMailer.test.deliver_now
TestHelperMailer.test.deliver_now
assert_emails 3
end

def test_assert_no_emails
assert_nothing_raised do
assert_no_emails do
TestHelperMailer.test
end
assert_no_emails do
TestHelperMailer.test
end
end

Expand Down Expand Up @@ -123,11 +111,9 @@ def test_assert_no_emails_failure
end

def test_assert_enqueued_emails
assert_nothing_raised do
assert_enqueued_emails 1 do
silence_stream($stdout) do
TestHelperMailer.test.deliver_later
end
assert_enqueued_emails 1 do
silence_stream($stdout) do
TestHelperMailer.test.deliver_later
end
end
end
Expand Down Expand Up @@ -158,10 +144,8 @@ def test_assert_enqueued_emails_too_many_sent
end

def test_assert_no_enqueued_emails
assert_nothing_raised do
assert_no_enqueued_emails do
TestHelperMailer.test.deliver_now
end
assert_no_enqueued_emails do
TestHelperMailer.test.deliver_now
end
end

Expand Down
4 changes: 2 additions & 2 deletions actionmailer/test/url_test.rb
Expand Up @@ -121,14 +121,14 @@ def test_signed_up_with_url
expected.content_type = "text/html"

created = nil
assert_nothing_raised { created = UrlTestMailer.signed_up_with_url(@recipient) }
created = UrlTestMailer.signed_up_with_url(@recipient)
assert_not_nil created

expected.message_id = '<123@456>'
created.message_id = '<123@456>'
assert_dom_equal expected.encoded, created.encoded

assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver_now }
UrlTestMailer.signed_up_with_url(@recipient).deliver_now
assert_not_nil ActionMailer::Base.deliveries.first
delivered = ActionMailer::Base.deliveries.first

Expand Down
9 changes: 3 additions & 6 deletions actionpack/test/controller/action_pack_assertions_test.rb
Expand Up @@ -420,13 +420,10 @@ def test_redirected_to_url_full_url

def test_assert_redirection_with_symbol
process :redirect_to_controller_with_symbol
assert_nothing_raised {
assert_redirected_to :controller => "elsewhere", :action => "flash_me"
}
assert_redirected_to :controller => "elsewhere", :action => "flash_me"

process :redirect_to_controller_with_symbol
assert_nothing_raised {
assert_redirected_to :controller => :elsewhere, :action => :flash_me
}
assert_redirected_to :controller => :elsewhere, :action => :flash_me
end

def test_redirected_to_with_nested_controller
Expand Down
10 changes: 2 additions & 8 deletions actionpack/test/controller/caching_test.rb
Expand Up @@ -311,10 +311,7 @@ def test_output_buffer
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)

assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end

def test_safe_buffer
Expand All @@ -326,10 +323,7 @@ def test_safe_buffer
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)

assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end
end

Expand Down
46 changes: 19 additions & 27 deletions actionpack/test/controller/filters_test.rb
Expand Up @@ -552,9 +552,7 @@ def find_except

def test_non_yielding_around_actions_do_not_raise
controller = NonYieldingAroundFilterController.new
assert_nothing_raised do
test_process(controller, "index")
end
test_process(controller, "index")
end

def test_after_actions_are_not_run_if_around_action_does_not_yield
Expand Down Expand Up @@ -753,15 +751,11 @@ def test_before_action_redirects_breaks_actioning_chain_for_preprend_after_actio
end

def test_actions_with_mixed_specialization_run_in_order
assert_nothing_raised do
response = test_process(MixedSpecializationController, 'bar')
assert_equal 'bar', response.body
end
response = test_process(MixedSpecializationController, 'bar')
assert_equal 'bar', response.body

assert_nothing_raised do
response = test_process(MixedSpecializationController, 'foo')
assert_equal 'foo', response.body
end
response = test_process(MixedSpecializationController, 'foo')
assert_equal 'foo', response.body
end

def test_dynamic_dispatch
Expand Down Expand Up @@ -825,9 +819,7 @@ def test_changing_the_requirements

def test_a_rescuing_around_action
response = nil
assert_nothing_raised do
response = test_process(RescuedController)
end
response = test_process(RescuedController)

assert response.success?
assert_equal("I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>", response.body)
Expand Down Expand Up @@ -982,29 +974,29 @@ class YieldingAroundFiltersTest < ActionController::TestCase

def test_base
controller = PostsController
assert_nothing_raised { test_process(controller,'no_raise') }
assert_nothing_raised { test_process(controller,'raises_before') }
assert_nothing_raised { test_process(controller,'raises_after') }
assert_nothing_raised { test_process(controller,'no_action') }
test_process(controller,'no_raise')
test_process(controller,'raises_before')
test_process(controller,'raises_after')
test_process(controller,'no_action')
end

def test_with_symbol
controller = ControllerWithSymbolAsFilter
assert_nothing_raised { test_process(controller,'no_raise') }
test_process(controller,'no_raise')
assert_raise(Before) { test_process(controller,'raises_before') }
assert_raise(After) { test_process(controller,'raises_after') }
assert_nothing_raised { test_process(controller,'no_raise') }
test_process(controller,'no_raise')
end

def test_with_class
controller = ControllerWithFilterClass
assert_nothing_raised { test_process(controller,'no_raise') }
test_process(controller,'no_raise')
assert_raise(After) { test_process(controller,'raises_after') }
end

def test_with_instance
controller = ControllerWithFilterInstance
assert_nothing_raised { test_process(controller,'no_raise') }
test_process(controller,'no_raise')
assert_raise(After) { test_process(controller,'raises_after') }
end

Expand All @@ -1016,12 +1008,12 @@ def test_with_proc

def test_nested_actions
controller = ControllerWithNestedFilters
assert_nothing_raised do
begin
test_process(controller,'raises_both')
rescue Before, After
end

begin
test_process(controller,'raises_both')
rescue Before, After
end

assert_raise Before do
begin
test_process(controller,'raises_both')
Expand Down
14 changes: 5 additions & 9 deletions actionpack/test/controller/helper_test.rb
Expand Up @@ -125,17 +125,17 @@ def setup

def test_helper
assert_equal expected_helper_methods, missing_methods
assert_nothing_raised { @controller_class.helper TestHelper }
@controller_class.helper TestHelper
assert_equal [], missing_methods
end

def test_helper_method
assert_nothing_raised { @controller_class.helper_method :delegate_method }
@controller_class.helper_method :delegate_method
assert master_helper_methods.include?(:delegate_method)
end

def test_helper_attr
assert_nothing_raised { @controller_class.helper_attr :delegate_attr }
@controller_class.helper_attr :delegate_attr
assert master_helper_methods.include?(:delegate_attr)
assert master_helper_methods.include?(:delegate_attr=)
end
Expand Down Expand Up @@ -170,15 +170,11 @@ def test_default_helpers_only
end

def test_base_helper_methods_after_clear_helpers
assert_nothing_raised do
call_controller(JustMeController, "flash")
end
call_controller(JustMeController, "flash")
end

def test_lib_helper_methods_after_clear_helpers
assert_nothing_raised do
call_controller(JustMeController, "lib")
end
call_controller(JustMeController, "lib")
end

def test_all_helpers
Expand Down
6 changes: 2 additions & 4 deletions actionpack/test/controller/integration_test.rb
Expand Up @@ -352,7 +352,7 @@ def test_integration_methods_called
@integration_session.stubs(:process)

%w( get post head patch put delete ).each do |verb|
assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') }
__send__(verb, '/')
end
end
end
Expand Down Expand Up @@ -987,9 +987,7 @@ def app
end

test "get /foo/status with head result does not cause stack overflow error" do
assert_nothing_raised do
get '/foo/status'
end
get '/foo/status'
assert_response :ok
end
end
Expand Down
4 changes: 1 addition & 3 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -567,9 +567,7 @@ def test_head_with_status_code_first
end

def test_head_returns_truthy_value
assert_nothing_raised do
get :head_and_return
end
get :head_and_return
end
end

Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/request_forgery_protection_test.rb
Expand Up @@ -389,7 +389,7 @@ def assert_blocked
end

def assert_not_blocked
assert_nothing_raised { yield }
yield
assert_response :success
end

Expand Down Expand Up @@ -520,7 +520,7 @@ def test_should_not_render_button_to_with_token_tag

def test_should_allow_all_methods_without_token
[:post, :patch, :put, :delete].each do |method|
assert_nothing_raised { send(method, :index)}
send(method, :index)
end
end

Expand Down

0 comments on commit 718eac6

Please sign in to comment.