Permalink
Browse files

Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.

[#1617 state:resolved]
  • Loading branch information...
1 parent 0c40789 commit 1c36172c13fc51b22167f5e8fc41b1da9f8fcb2a @jeremy jeremy committed Mar 8, 2009
Showing with 294 additions and 294 deletions.
  1. +1 −1 actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
  2. +1 −1 actionmailer/test/mail_service_test.rb
  3. +4 −4 actionmailer/test/test_helper_test.rb
  4. +28 −28 actionpack/test/controller/assert_select_test.rb
  5. +1 −1 actionpack/test/controller/html-scanner/document_test.rb
  6. +1 −1 actionpack/test/controller/mime_responds_test.rb
  7. +2 −2 actionpack/test/controller/redirect_test.rb
  8. +7 −7 actionpack/test/controller/render_test.rb
  9. +9 −9 actionpack/test/controller/request_forgery_protection_test.rb
  10. +3 −3 actionpack/test/controller/request_test.rb
  11. +6 −6 actionpack/test/controller/resources_test.rb
  12. +27 −27 actionpack/test/controller/routing_test.rb
  13. +3 −3 actionpack/test/controller/selector_test.rb
  14. +1 −1 actionpack/test/controller/send_file_test.rb
  15. +1 −1 actionpack/test/controller/url_rewriter_test.rb
  16. +1 −1 actionpack/test/template/url_helper_test.rb
  17. +1 −1 activemodel/test/state_machine/event_test.rb
  18. +2 −2 activerecord/test/cases/associations/belongs_to_associations_test.rb
  19. +4 −4 activerecord/test/cases/associations/eager_test.rb
  20. +1 −1 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  21. +13 −13 activerecord/test/cases/associations/has_many_associations_test.rb
  22. +5 −5 activerecord/test/cases/associations/has_one_associations_test.rb
  23. +2 −2 activerecord/test/cases/associations/has_one_through_associations_test.rb
  24. +1 −1 activerecord/test/cases/attribute_methods_test.rb
  25. +9 −9 activerecord/test/cases/base_test.rb
  26. +2 −2 activerecord/test/cases/calculations_test.rb
  27. +2 −2 activerecord/test/cases/callbacks_test.rb
  28. +1 −1 activerecord/test/cases/dirty_test.rb
  29. +32 −32 activerecord/test/cases/finder_test.rb
  30. +2 −2 activerecord/test/cases/fixtures_test.rb
  31. +2 −2 activerecord/test/cases/inheritance_test.rb
  32. +5 −5 activerecord/test/cases/locking_test.rb
  33. +13 −13 activerecord/test/cases/migration_test.rb
  34. +2 −2 activerecord/test/cases/transactions_test.rb
  35. +6 −6 activerecord/test/cases/validations_test.rb
  36. +4 −4 activeresource/test/authorization_test.rb
  37. +10 −10 activeresource/test/base_test.rb
  38. +2 −2 activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb
  39. +13 −13 activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb
  40. +3 −3 activesupport/test/core_ext/class_test.rb
  41. +2 −2 activesupport/test/core_ext/hash_ext_test.rb
  42. +2 −2 activesupport/test/core_ext/load_error_test.rb
  43. +2 −2 activesupport/test/core_ext/module/synchronization_test.rb
  44. +5 −5 activesupport/test/core_ext/module_test.rb
  45. +2 −2 activesupport/test/core_ext/object_and_class_ext_test.rb
  46. +1 −1 activesupport/test/core_ext/time_with_zone_test.rb
  47. +11 −11 activesupport/test/dependencies_test.rb
  48. +4 −4 activesupport/test/inflector_test.rb
  49. +1 −1 activesupport/test/json/decoding_test.rb
  50. +1 −1 activesupport/test/json/encoding_test.rb
  51. +1 −1 activesupport/test/message_encryptor_test.rb
  52. +1 −1 activesupport/test/message_verifier_test.rb
  53. +17 −17 activesupport/test/multibyte_chars_test.rb
  54. +1 −1 activesupport/test/string_inquirer_test.rb
  55. +1 −1 activesupport/test/time_zone_test.rb
  56. +1 −1 railties/guides/source/testing.textile
  57. +1 −1 railties/test/initializer_test.rb
  58. +1 −1 railties/test/plugin_locator_test.rb
  59. +6 −6 railties/test/plugin_test.rb
@@ -1150,7 +1150,7 @@ def test_format_style
assert_equal(Text::Format::JUSTIFY, @format_o.format_style)
assert_match(/^of freedom, and that government of the people, by the people, for the$/,
@format_o.format(GETTYSBURG).split("\n")[-3])
- assert_raises(ArgumentError) { @format_o.format_style = 33 }
+ assert_raise(ArgumentError) { @format_o.format_style = 33 }
end
def test_tag_paragraph
@@ -1069,7 +1069,7 @@ def test_should_not_respond_to_method_where_deliver_is_not_a_suffix
end
def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method
- error = assert_raises NoMethodError do
+ error = assert_raise NoMethodError do
RespondToMailer.not_a_method
end
@@ -26,7 +26,7 @@ def test_mailer_class_is_correctly_inferred
end
def test_determine_default_mailer_raises_correct_error
- assert_raises(ActionMailer::NonInferrableMailerError) do
+ assert_raise(ActionMailer::NonInferrableMailerError) do
self.class.determine_default_mailer("NotAMailerTest")
end
end
@@ -84,7 +84,7 @@ def test_assert_no_emails
end
def test_assert_emails_too_few_sent
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 2 do
TestHelperMailer.deliver_test
end
@@ -94,7 +94,7 @@ def test_assert_emails_too_few_sent
end
def test_assert_emails_too_many_sent
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 1 do
TestHelperMailer.deliver_test
TestHelperMailer.deliver_test
@@ -105,7 +105,7 @@ def test_assert_emails_too_many_sent
end
def test_assert_no_emails_failure
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_no_emails do
TestHelperMailer.deliver_test
end
@@ -76,7 +76,7 @@ def teardown
end
def assert_failure(message, &block)
- e = assert_raises(Assertion, &block)
+ e = assert_raise(Assertion, &block)
assert_match(message, e.message) if Regexp === message
assert_equal(message, e.message) if String === message
end
@@ -95,42 +95,42 @@ def test_assert_select
def test_equality_true_false
render_html %Q{<div id="1"></div><div id="2"></div>}
assert_nothing_raised { assert_select "div" }
- assert_raises(Assertion) { assert_select "p" }
+ assert_raise(Assertion) { assert_select "p" }
assert_nothing_raised { assert_select "div", true }
- assert_raises(Assertion) { assert_select "p", true }
- assert_raises(Assertion) { assert_select "div", false }
+ assert_raise(Assertion) { assert_select "p", true }
+ assert_raise(Assertion) { assert_select "div", false }
assert_nothing_raised { assert_select "p", false }
end
def test_equality_string_and_regexp
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
assert_nothing_raised { assert_select "div", "foo" }
- assert_raises(Assertion) { assert_select "div", "bar" }
+ assert_raise(Assertion) { assert_select "div", "bar" }
assert_nothing_raised { assert_select "div", :text=>"foo" }
- assert_raises(Assertion) { assert_select "div", :text=>"bar" }
+ assert_raise(Assertion) { assert_select "div", :text=>"bar" }
assert_nothing_raised { assert_select "div", /(foo|bar)/ }
- assert_raises(Assertion) { assert_select "div", /foobar/ }
+ assert_raise(Assertion) { assert_select "div", /foobar/ }
assert_nothing_raised { assert_select "div", :text=>/(foo|bar)/ }
- assert_raises(Assertion) { assert_select "div", :text=>/foobar/ }
- assert_raises(Assertion) { assert_select "p", :text=>/foobar/ }
+ assert_raise(Assertion) { assert_select "div", :text=>/foobar/ }
+ assert_raise(Assertion) { assert_select "p", :text=>/foobar/ }
end
def test_equality_of_html
render_html %Q{<p>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</p>}
text = "\"This is not a big problem,\" he said."
html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said."
assert_nothing_raised { assert_select "p", text }
- assert_raises(Assertion) { assert_select "p", html }
+ assert_raise(Assertion) { assert_select "p", html }
assert_nothing_raised { assert_select "p", :html=>html }
- assert_raises(Assertion) { assert_select "p", :html=>text }
+ assert_raise(Assertion) { assert_select "p", :html=>text }
# No stripping for pre.
render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>}
text = "\n\"This is not a big problem,\" he said.\n"
html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n"
assert_nothing_raised { assert_select "pre", text }
- assert_raises(Assertion) { assert_select "pre", html }
+ assert_raise(Assertion) { assert_select "pre", html }
assert_nothing_raised { assert_select "pre", :html=>html }
- assert_raises(Assertion) { assert_select "pre", :html=>text }
+ assert_raise(Assertion) { assert_select "pre", :html=>text }
end
def test_counts
@@ -210,12 +210,12 @@ def test_assert_select_text_match
assert_nothing_raised { assert_select "div", "bar" }
assert_nothing_raised { assert_select "div", /\w*/ }
assert_nothing_raised { assert_select "div", /\w*/, :count=>2 }
- assert_raises(Assertion) { assert_select "div", :text=>"foo", :count=>2 }
+ assert_raise(Assertion) { assert_select "div", :text=>"foo", :count=>2 }
assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" }
assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" }
assert_nothing_raised { assert_select "div", :html=>/\w*/ }
assert_nothing_raised { assert_select "div", :html=>/\w*/, :count=>2 }
- assert_raises(Assertion) { assert_select "div", :html=>"<span>foo</span>", :count=>2 }
+ assert_raise(Assertion) { assert_select "div", :html=>"<span>foo</span>", :count=>2 }
end
end
@@ -253,7 +253,7 @@ def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_argumen
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
end
- assert_raises(Assertion) {assert_select_rjs :insert, :top, "test2"}
+ assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"}
end
def test_elect_with_xml_namespace_attributes
@@ -336,7 +336,7 @@ def test_assert_select_rjs_picks_up_all_statements
# Test that we fail if there is nothing to pick.
def test_assert_select_rjs_fails_if_nothing_to_pick
render_rjs { }
- assert_raises(Assertion) { assert_select_rjs }
+ assert_raise(Assertion) { assert_select_rjs }
end
def test_assert_select_rjs_with_unicode
@@ -351,10 +351,10 @@ def test_assert_select_rjs_with_unicode
if str.respond_to?(:force_encoding)
str.force_encoding(Encoding::UTF_8)
assert_select str, /\343\203\201..\343\203\210/u
- assert_raises(Assertion) { assert_select str, /\343\203\201.\343\203\210/u }
+ assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u }
else
assert_select str, Regexp.new("\343\203\201..\343\203\210",0,'U')
- assert_raises(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') }
+ assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') }
end
end
end
@@ -378,7 +378,7 @@ def test_assert_select_rjs_with_id
assert_select "div", 1
assert_select "#3"
end
- assert_raises(Assertion) { assert_select_rjs "test4" }
+ assert_raise(Assertion) { assert_select_rjs "test4" }
end
def test_assert_select_rjs_for_replace
@@ -396,7 +396,7 @@ def test_assert_select_rjs_for_replace
assert_select "div", 1
assert_select "#1"
end
- assert_raises(Assertion) { assert_select_rjs :replace, "test2" }
+ assert_raise(Assertion) { assert_select_rjs :replace, "test2" }
# Replace HTML.
assert_select_rjs :replace_html do
assert_select "div", 1
@@ -406,7 +406,7 @@ def test_assert_select_rjs_for_replace
assert_select "div", 1
assert_select "#2"
end
- assert_raises(Assertion) { assert_select_rjs :replace_html, "test1" }
+ assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
end
def test_assert_select_rjs_for_chained_replace
@@ -424,7 +424,7 @@ def test_assert_select_rjs_for_chained_replace
assert_select "div", 1
assert_select "#1"
end
- assert_raises(Assertion) { assert_select_rjs :chained_replace, "test2" }
+ assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" }
# Replace HTML.
assert_select_rjs :chained_replace_html do
assert_select "div", 1
@@ -434,7 +434,7 @@ def test_assert_select_rjs_for_chained_replace
assert_select "div", 1
assert_select "#2"
end
- assert_raises(Assertion) { assert_select_rjs :replace_html, "test1" }
+ assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
end
# Simple remove
@@ -580,7 +580,7 @@ def test_assert_select_rjs_for_nonpositioned_insert
assert_select "div", 1
assert_select "#3"
end
- assert_raises(Assertion) { assert_select_rjs :insert_html, "test1" }
+ assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" }
end
# Positioned insert.
@@ -613,8 +613,8 @@ def test_assert_select_rjs_for_positioned_insert
end
def test_assert_select_rjs_raise_errors
- assert_raises(ArgumentError) { assert_select_rjs(:destroy) }
- assert_raises(ArgumentError) { assert_select_rjs(:insert, :left) }
+ assert_raise(ArgumentError) { assert_select_rjs(:destroy) }
+ assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) }
end
# Simple selection from a single result.
@@ -706,7 +706,7 @@ def test_feed_item_encoded
#
def test_assert_select_email
- assert_raises(Assertion) { assert_select_email {} }
+ assert_raise(Assertion) { assert_select_email {} }
AssertSelectMailer.deliver_test "<div><p>foo</p><p>bar</p></div>"
assert_select_email do
assert_select "div:root" do
@@ -134,7 +134,7 @@ def test_parse_invalid_document
end
def test_invalid_document_raises_exception_when_strict
- assert_raises RuntimeError do
+ assert_raise RuntimeError do
doc = HTML::Document.new("<html>
<table>
<tr>
@@ -469,7 +469,7 @@ def test_format_with_custom_response_type_and_request_headers_with_only_one_layo
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
@request.accept = "text/iphone"
- assert_raises(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
+ assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
end
end
@@ -212,7 +212,7 @@ def test_redirect_to_back
end
def test_redirect_to_back_with_no_referer
- assert_raises(ActionController::RedirectBackError) {
+ assert_raise(ActionController::RedirectBackError) {
@request.env["HTTP_REFERER"] = nil
get :redirect_to_back
}
@@ -239,7 +239,7 @@ def test_redirect_with_partial_params
end
def test_redirect_to_nil
- assert_raises(ActionController::ActionControllerError) do
+ assert_raise(ActionController::ActionControllerError) do
get :redirect_to_nil
end
end
@@ -937,11 +937,11 @@ def test_render_nothing_with_appendix
end
def test_attempt_to_access_object_method
- assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
+ assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
end
def test_private_methods
- assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
+ assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
end
def test_access_to_request_in_view
@@ -1173,7 +1173,7 @@ def test_render_to_string_doesnt_break_assigns
end
def test_bad_render_to_string_still_throws_exception
- assert_raises(ActionView::MissingTemplate) { get :render_to_string_with_exception }
+ assert_raise(ActionView::MissingTemplate) { get :render_to_string_with_exception }
end
def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns
@@ -1198,15 +1198,15 @@ def test_render_with_explicit_string_template
end
def test_double_render
- assert_raises(ActionController::DoubleRenderError) { get :double_render }
+ assert_raise(ActionController::DoubleRenderError) { get :double_render }
end
def test_double_redirect
- assert_raises(ActionController::DoubleRenderError) { get :double_redirect }
+ assert_raise(ActionController::DoubleRenderError) { get :double_redirect }
end
def test_render_and_redirect
- assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect }
+ assert_raise(ActionController::DoubleRenderError) { get :render_and_redirect }
end
# specify the one exception to double render rule - render_to_string followed by render
@@ -1515,7 +1515,7 @@ def test_partial_with_implicit_local_assignment
end
def test_render_missing_partial_template
- assert_raises(ActionView::MissingTemplate) do
+ assert_raise(ActionView::MissingTemplate) do
get :missing_partial
end
end
@@ -79,17 +79,17 @@ def test_should_allow_post_without_token_on_unsafe_action
def test_should_not_allow_html_post_without_token
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
- assert_raises(ActionController::InvalidAuthenticityToken) { post :index, :format => :html }
+ assert_raise(ActionController::InvalidAuthenticityToken) { post :index, :format => :html }
end
def test_should_not_allow_html_put_without_token
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
- assert_raises(ActionController::InvalidAuthenticityToken) { put :index, :format => :html }
+ assert_raise(ActionController::InvalidAuthenticityToken) { put :index, :format => :html }
end
def test_should_not_allow_html_delete_without_token
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
- assert_raises(ActionController::InvalidAuthenticityToken) { delete :index, :format => :html }
+ assert_raise(ActionController::InvalidAuthenticityToken) { delete :index, :format => :html }
end
def test_should_allow_api_formatted_post_without_token
@@ -111,42 +111,42 @@ def test_should_allow_api_formatted_delete_without_token
end
def test_should_not_allow_api_formatted_post_sent_as_url_encoded_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
post :index, :format => 'xml'
end
end
def test_should_not_allow_api_formatted_put_sent_as_url_encoded_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
put :index, :format => 'xml'
end
end
def test_should_not_allow_api_formatted_delete_sent_as_url_encoded_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s
delete :index, :format => 'xml'
end
end
def test_should_not_allow_api_formatted_post_sent_as_multipart_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s
post :index, :format => 'xml'
end
end
def test_should_not_allow_api_formatted_put_sent_as_multipart_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s
put :index, :format => 'xml'
end
end
def test_should_not_allow_api_formatted_delete_sent_as_multipart_form_without_token
- assert_raises(ActionController::InvalidAuthenticityToken) do
+ assert_raise(ActionController::InvalidAuthenticityToken) do
@request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s
delete :index, :format => 'xml'
end
Oops, something went wrong.

0 comments on commit 1c36172

Please sign in to comment.