From 1e66673482b03b42729fe1fad863c4ba4bc27037 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Tue, 30 Dec 2008 17:50:18 +0100 Subject: [PATCH] Removed the use of deprecated assertion method Replaced all occurrences of assert_raises with assert_raise, as the former is deprecated in Ruby 1.9. --- .../vendor/text-format-0.6.3/text/format.rb | 2 +- actionmailer/test/mail_service_test.rb | 2 +- actionmailer/test/test_helper_test.rb | 8 +- actionpack/test/controller/assert_select_test.rb | 56 +++++++++--------- .../test/controller/html-scanner/document_test.rb | 2 +- actionpack/test/controller/mime_responds_test.rb | 2 +- actionpack/test/controller/redirect_test.rb | 4 +- actionpack/test/controller/render_test.rb | 14 ++-- .../controller/request_forgery_protection_test.rb | 18 +++--- actionpack/test/controller/request_test.rb | 6 +- actionpack/test/controller/resources_test.rb | 12 ++-- actionpack/test/controller/routing_test.rb | 52 ++++++++-------- actionpack/test/controller/selector_test.rb | 6 +- actionpack/test/controller/send_file_test.rb | 2 +- actionpack/test/controller/url_rewriter_test.rb | 2 +- actionpack/test/template/url_helper_test.rb | 2 +- activemodel/test/state_machine/event_test.rb | 2 +- .../associations/belongs_to_associations_test.rb | 4 +- activerecord/test/cases/associations/eager_test.rb | 8 +- .../has_and_belongs_to_many_associations_test.rb | 2 +- .../associations/has_many_associations_test.rb | 26 ++++---- .../associations/has_one_associations_test.rb | 10 ++-- .../has_one_through_associations_test.rb | 4 +- activerecord/test/cases/attribute_methods_test.rb | 2 +- activerecord/test/cases/base_test.rb | 18 +++--- activerecord/test/cases/calculations_test.rb | 4 +- activerecord/test/cases/callbacks_test.rb | 4 +- activerecord/test/cases/dirty_test.rb | 2 +- activerecord/test/cases/finder_test.rb | 62 ++++++++++---------- activerecord/test/cases/fixtures_test.rb | 4 +- activerecord/test/cases/inheritance_test.rb | 4 +- activerecord/test/cases/locking_test.rb | 10 ++-- activerecord/test/cases/migration_test.rb | 26 ++++---- activerecord/test/cases/transactions_test.rb | 2 +- activerecord/test/cases/validations_test.rb | 12 ++-- activeresource/test/authorization_test.rb | 8 +- activeresource/test/base_test.rb | 20 +++--- .../vendor/i18n-0.1.1/test/i18n_test.rb | 4 +- .../vendor/i18n-0.1.1/test/simple_backend_test.rb | 22 ++++---- activesupport/test/core_ext/class_test.rb | 6 +- activesupport/test/core_ext/hash_ext_test.rb | 4 +- activesupport/test/core_ext/load_error_test.rb | 4 +- .../test/core_ext/module/synchronization_test.rb | 4 +- activesupport/test/core_ext/module_test.rb | 10 ++-- .../test/core_ext/object_and_class_ext_test.rb | 2 +- activesupport/test/core_ext/time_with_zone_test.rb | 2 +- activesupport/test/dependencies_test.rb | 22 ++++---- activesupport/test/inflector_test.rb | 8 +- activesupport/test/json/decoding_test.rb | 2 +- activesupport/test/json/encoding_test.rb | 2 +- activesupport/test/message_encryptor_test.rb | 2 +- activesupport/test/message_verifier_test.rb | 2 +- activesupport/test/multibyte_chars_test.rb | 34 +++++----- activesupport/test/string_inquirer_test.rb | 2 +- activesupport/test/time_zone_test.rb | 2 +- .../guides/html/testing_rails_applications.html | 2 +- .../guides/source/testing_rails_applications.txt | 2 +- railties/test/initializer_test.rb | 2 +- railties/test/plugin_locator_test.rb | 2 +- railties/test/plugin_test.rb | 12 ++-- 60 files changed, 289 insertions(+), 289 deletions(-) diff --git a/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb b/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb index de054db..2d20c7a 100755 --- a/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +++ b/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb @@ -1150,7 +1150,7 @@ if __FILE__ == $0 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 diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 15a4055..cd96e40 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1059,7 +1059,7 @@ class RespondToTest < Test::Unit::TestCase 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 diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 9d22bb2..65b07a7 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -26,7 +26,7 @@ class TestHelperMailerTest < ActionMailer::TestCase 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 @@ class TestHelperMailerTest < ActionMailer::TestCase 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 @@ class TestHelperMailerTest < ActionMailer::TestCase 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 @@ class TestHelperMailerTest < ActionMailer::TestCase 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 diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index 99c57c0..ded3d87 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -76,7 +76,7 @@ class AssertSelectTest < ActionController::TestCase 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,24 +95,24 @@ class AssertSelectTest < ActionController::TestCase def test_equality_true_false render_html %Q{
} 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{
foo
foo
} 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 @@ -120,17 +120,17 @@ class AssertSelectTest < ActionController::TestCase text = "\"This is not a big problem,\" he said." html = "\"This is not a big problem,\" 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{
\n"This is not a big problem," he said.\n
} text = "\n\"This is not a big problem,\" he said.\n" html = "\n\"This is not a big problem,\" 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 @@ class AssertSelectTest < ActionController::TestCase 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=>"bar" } assert_nothing_raised { assert_select "div", :html=>"bar" } 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=>"foo", :count=>2 } + assert_raise(Assertion) { assert_select "div", :html=>"foo", :count=>2 } end end @@ -253,7 +253,7 @@ class AssertSelectTest < ActionController::TestCase page.insert_html :top, "test1", "
foo
" page.insert_html :bottom, "test2", "
foo
" end - assert_raises(Assertion) {assert_select_rjs :insert, :top, "test2"} + assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"} end # @@ -331,7 +331,7 @@ class AssertSelectTest < ActionController::TestCase # 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 @@ -346,10 +346,10 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -373,7 +373,7 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -391,7 +391,7 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -401,7 +401,7 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -419,7 +419,7 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -429,7 +429,7 @@ class AssertSelectTest < ActionController::TestCase 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 @@ -575,7 +575,7 @@ class AssertSelectTest < ActionController::TestCase 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. @@ -608,8 +608,8 @@ class AssertSelectTest < ActionController::TestCase 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. @@ -701,7 +701,7 @@ EOF # def test_assert_select_email - assert_raises(Assertion) { assert_select_email {} } + assert_raise(Assertion) { assert_select_email {} } AssertSelectMailer.deliver_test "

foo

bar

" assert_select_email do assert_select "div:root" do diff --git a/actionpack/test/controller/html-scanner/document_test.rb b/actionpack/test/controller/html-scanner/document_test.rb index 1c3facb..c68f04f 100644 --- a/actionpack/test/controller/html-scanner/document_test.rb +++ b/actionpack/test/controller/html-scanner/document_test.rb @@ -134,7 +134,7 @@ HTML end def test_invalid_document_raises_exception_when_strict - assert_raises RuntimeError do + assert_raise RuntimeError do doc = HTML::Document.new(" diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index dc59180..edd7162 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -469,7 +469,7 @@ class MimeControllerTest < ActionController::TestCase assert_equal '
Hello future from Firefox!
', @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 diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 27cedc9..91e21db 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -212,7 +212,7 @@ class RedirectTest < ActionController::TestCase 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 @@ class RedirectTest < ActionController::TestCase end def test_redirect_to_nil - assert_raises(ActionController::ActionControllerError) do + assert_raise(ActionController::ActionControllerError) do get :redirect_to_nil end end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 5fd41d8..8b097d7 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -877,11 +877,11 @@ class RenderTest < ActionController::TestCase 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 @@ -1098,7 +1098,7 @@ class RenderTest < ActionController::TestCase 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 @@ -1123,15 +1123,15 @@ class RenderTest < ActionController::TestCase 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 @@ -1425,7 +1425,7 @@ class RenderTest < ActionController::TestCase end def test_render_missing_partial_template - assert_raises(ActionView::MissingTemplate) do + assert_raise(ActionView::MissingTemplate) do get :missing_partial end end diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index ef0bf5f..835e73e 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -79,17 +79,17 @@ module RequestForgeryProtectionTests 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 @@ module RequestForgeryProtectionTests 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 diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 349cea2..93e598c 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -59,7 +59,7 @@ class RequestTest < ActiveSupport::TestCase assert_equal '3.4.5.6', @request.remote_ip(true) @request.env['HTTP_CLIENT_IP'] = '8.8.8.8' - e = assert_raises(ActionController::ActionControllerError) { + e = assert_raise(ActionController::ActionControllerError) { @request.remote_ip(true) } assert_match /IP spoofing attack/, e.message @@ -297,7 +297,7 @@ class RequestTest < ActiveSupport::TestCase end def test_invalid_http_method_raises_exception - assert_raises(ActionController::UnknownHttpMethod) do + assert_raise(ActionController::UnknownHttpMethod) do self.request_method = :random_method end end @@ -311,7 +311,7 @@ class RequestTest < ActiveSupport::TestCase end def test_invalid_method_hacking_on_post_raises_exception - assert_raises(ActionController::UnknownHttpMethod) do + assert_raise(ActionController::UnknownHttpMethod) do self.request_method = :_random_method @request.request_method(true) end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 8dedeb2..943f935 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -99,7 +99,7 @@ class ResourcesTest < ActionController::TestCase expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'} with_restful_routing :messages do - assert_raises(ActionController::RoutingError) do + assert_raise(ActionController::RoutingError) do assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get) end end @@ -325,7 +325,7 @@ class ResourcesTest < ActionController::TestCase with_restful_routing :messages do assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) - assert_raises(ActionController::MethodNotAllowed) do + assert_raise(ActionController::MethodNotAllowed) do ActionController::Routing::Routes.recognize_path("/messages/new", :method => :post) end end @@ -583,11 +583,11 @@ class ResourcesTest < ActionController::TestCase options = { :controller => controller_name.to_s } collection_path = "/#{controller_name}" - assert_raises(ActionController::MethodNotAllowed) do + assert_raise(ActionController::MethodNotAllowed) do assert_recognizes(options.merge(:action => 'update'), :path => collection_path, :method => :put) end - assert_raises(ActionController::MethodNotAllowed) do + assert_raise(ActionController::MethodNotAllowed) do assert_recognizes(options.merge(:action => 'destroy'), :path => collection_path, :method => :delete) end end @@ -596,7 +596,7 @@ class ResourcesTest < ActionController::TestCase def test_should_not_allow_invalid_head_method_for_member_routes with_routing do |set| set.draw do |map| - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do map.resources :messages, :member => {:something => :head} end end @@ -606,7 +606,7 @@ class ResourcesTest < ActionController::TestCase def test_should_not_allow_invalid_http_methods_for_member_routes with_routing do |set| set.draw do |map| - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do map.resources :messages, :member => {:something => :invalid} end end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index b981119..0b85a37 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -219,7 +219,7 @@ class DynamicSegmentTest < Test::Unit::TestCase a_value = nil # Local jump because of return inside eval. - assert_raises(LocalJumpError) { eval(segment.extraction_code) } + assert_raise(LocalJumpError) { eval(segment.extraction_code) } end def test_extraction_code_should_return_on_mismatch @@ -229,7 +229,7 @@ class DynamicSegmentTest < Test::Unit::TestCase a_value = nil # Local jump because of return inside eval. - assert_raises(LocalJumpError) { eval(segment.extraction_code) } + assert_raise(LocalJumpError) { eval(segment.extraction_code) } end def test_extraction_code_should_accept_value_and_set_local @@ -470,7 +470,7 @@ class RouteBuilderTest < Test::Unit::TestCase defaults = {:action => 'buy', :person => nil, :car => nil} requirements = {:person => /\w+/, :car => /^\w+$/} - assert_raises ArgumentError do + assert_raise ArgumentError do route_requirements = builder.assign_route_options(segments, defaults, requirements) end @@ -1028,11 +1028,11 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do rs.draw do |map| map.connect ':controller/:action/:id' end - assert_raises(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") } + assert_raise(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") } end def test_paths_do_not_accept_defaults - assert_raises(ActionController::RoutingError) do + assert_raise(ActionController::RoutingError) do rs.draw do |map| map.path 'file/*path', :controller => 'content', :action => 'show_file', :path => %w(fake default) map.connect ':controller/:action/:id' @@ -1164,7 +1164,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do assert_equal '/post/10', rs.generate(:controller => 'post', :action => 'show', :id => 10) - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do rs.generate(:controller => 'post', :action => 'show') end end @@ -1374,7 +1374,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end x = setup_for_named_route - assert_raises(ActionController::RoutingError) do + assert_raise(ActionController::RoutingError) do x.send(:foo_with_requirement_url, "I am Against the requirements") end end @@ -1506,7 +1506,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end def test_builder_complains_without_controller - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do ROUTING::RouteBuilder.new.build '/contact', :contoller => "contact", :action => "index" end end @@ -1789,27 +1789,27 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end def test_route_requirements_with_anchor_chars_are_invalid - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /^\d+/ end end - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\A\d+/ end end - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+$/ end end - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\Z/ end end - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\z/ end @@ -1818,14 +1818,14 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do set.draw do |map| map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/, :name => /^(david|jamis)/ end - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.generate :controller => 'pages', :action => 'show', :id => 10 end end end def test_route_requirements_with_invalid_http_method_is_invalid - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :invalid} end @@ -1833,7 +1833,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end def test_route_requirements_with_head_method_condition_is_invalid - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :head} end @@ -1845,10 +1845,10 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do map.connect 'page/37s', :controller => 'pages', :action => 'show', :name => /(jamis|david)/ end assert_equal '/page/37s', set.generate(:controller => 'pages', :action => 'show', :name => 'jamis') - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.generate(:controller => 'pages', :action => 'show', :name => 'not_jamis') end - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.generate(:controller => 'pages', :action => 'show', :name => 'nor_jamis_and_david') end end @@ -1891,7 +1891,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do assert_equal("update", request.path_parameters[:action]) request.recycle! - assert_raises(ActionController::UnknownHttpMethod) { + assert_raise(ActionController::UnknownHttpMethod) { request.env["REQUEST_METHOD"] = "BACON" set.recognize(request) } @@ -2260,7 +2260,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end def test_route_requirements_with_unsupported_regexp_options_must_error - assert_raises ArgumentError do + assert_raise ArgumentError do set.draw do |map| map.connect 'page/:name', :controller => 'pages', :action => 'show', @@ -2298,7 +2298,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do :requirements => {:name => /(david|jamis)/i} end assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.recognize_path('/page/davidjamis') end assert_equal({:controller => 'pages', :action => 'show', :name => 'DAVID'}, set.recognize_path('/page/DAVID')) @@ -2312,7 +2312,7 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) assert_equal "/page/david", url - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) end url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) @@ -2332,10 +2332,10 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) assert_equal({:controller => 'pages', :action => 'show', :name => 'david'}, set.recognize_path('/page/david')) - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.recognize_path('/page/david #The Creator') end - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do set.recognize_path('/page/David') end end @@ -2353,10 +2353,10 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) assert_equal "/page/david", url - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) end - assert_raises ActionController::RoutingError do + assert_raise ActionController::RoutingError do url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) end end diff --git a/actionpack/test/controller/selector_test.rb b/actionpack/test/controller/selector_test.rb index 4e31b45..9d0613d 100644 --- a/actionpack/test/controller/selector_test.rb +++ b/actionpack/test/controller/selector_test.rb @@ -303,7 +303,7 @@ class SelectorTest < Test::Unit::TestCase assert_equal 1, @matches.size assert_equal "2", @matches[0].attributes["id"] # Before first and past last returns nothing.: - assert_raises(ArgumentError) { select("tr:nth-child(-1)") } + assert_raise(ArgumentError) { select("tr:nth-child(-1)") } select("tr:nth-child(0)") assert_equal 0, @matches.size select("tr:nth-child(5)") @@ -597,8 +597,8 @@ class SelectorTest < Test::Unit::TestCase def test_negation_details parse(%Q{

}) - assert_raises(ArgumentError) { select(":not(") } - assert_raises(ArgumentError) { select(":not(:not())") } + assert_raise(ArgumentError) { select(":not(") } + assert_raise(ArgumentError) { select(":not(:not())") } select("p:not(#1):not(#3)") assert_equal 1, @matches.size assert_equal "2", @matches[0].attributes["id"] diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 1b7486a..64b3dfa 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -141,7 +141,7 @@ class SendFileTest < Test::Unit::TestCase } @controller.headers = {} - assert_raises(ArgumentError){ @controller.send(:send_file_headers!, options) } + assert_raise(ArgumentError){ @controller.send(:send_file_headers!, options) } end %w(file data).each do |method| diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index e9d3725..b177b65 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -99,7 +99,7 @@ class UrlWriterTests < ActionController::TestCase end def test_exception_is_thrown_without_host - assert_raises RuntimeError do + assert_raise RuntimeError do W.new.url_for :controller => 'c', :action => 'a', :id => 'i' end end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 2f6fa13..5ec50e0 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -220,7 +220,7 @@ class UrlHelperTest < ActionView::TestCase end def test_link_tag_using_post_javascript_and_popup - assert_raises(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } + assert_raise(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } end def test_link_tag_using_block_in_erb diff --git a/activemodel/test/state_machine/event_test.rb b/activemodel/test/state_machine/event_test.rb index 8fb7e82..64dc8c4 100644 --- a/activemodel/test/state_machine/event_test.rb +++ b/activemodel/test/state_machine/event_test.rb @@ -31,7 +31,7 @@ class EventBeingFiredTest < ActiveModel::TestCase test 'should raise an AASM::InvalidTransition error if the transitions are empty' do event = ActiveModel::StateMachine::Event.new(nil, :event) - assert_raises ActiveModel::StateMachine::InvalidTransition do + assert_raise ActiveModel::StateMachine::InvalidTransition do event.fire(nil) end end diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 40a8503..1ff7279 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -430,8 +430,8 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase end def test_belongs_to_proxy_should_not_respond_to_private_methods - assert_raises(NoMethodError) { companies(:first_firm).private_method } - assert_raises(NoMethodError) { companies(:second_client).firm.private_method } + assert_raise(NoMethodError) { companies(:first_firm).private_method } + assert_raise(NoMethodError) { companies(:second_client).firm.private_method } end def test_belongs_to_proxy_should_respond_to_private_methods_via_send diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index afbd9fd..d2baf15 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -549,16 +549,16 @@ class EagerAssociationTest < ActiveRecord::TestCase end def test_eager_with_invalid_association_reference - assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { + assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { post = Post.find(6, :include=> :monkeys ) } - assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { + assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { post = Post.find(6, :include=>[ :monkeys ]) } - assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { + assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { post = Post.find(6, :include=>[ 'monkeys' ]) } - assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") { + assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") { post = Post.find(6, :include=>[ :monkeys, :elephants ]) } end diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 2f08e09..010b52d 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -616,7 +616,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase def test_updating_attributes_on_rich_associations david = projects(:action_controller).developers.first david.name = "DHH" - assert_raises(ActiveRecord::ReadOnlyRecord) { david.save! } + assert_raise(ActiveRecord::ReadOnlyRecord) { david.save! } end def test_updating_attributes_on_rich_associations_with_limited_find_from_reflection diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 20b9acd..45a23ff 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -176,7 +176,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase def test_find_ids firm = Firm.find(:first) - assert_raises(ActiveRecord::RecordNotFound) { firm.clients.find } + assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find } client = firm.clients.find(2) assert_kind_of Client, client @@ -190,7 +190,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 2, client_ary.size assert_equal client, client_ary.first - assert_raises(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) } + assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) } end def test_find_string_ids_when_using_finder_sql @@ -238,7 +238,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase def test_find_in_collection assert_equal Client.find(2).name, companies(:first_firm).clients.find(2).name - assert_raises(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) } + assert_raise(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) } end def test_find_grouped @@ -278,36 +278,36 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_create_with_bang_on_has_many_when_parent_is_new_raises - assert_raises(ActiveRecord::RecordNotSaved) do + assert_raise(ActiveRecord::RecordNotSaved) do firm = Firm.new firm.plain_clients.create! :name=>"Whoever" end end def test_regular_create_on_has_many_when_parent_is_new_raises - assert_raises(ActiveRecord::RecordNotSaved) do + assert_raise(ActiveRecord::RecordNotSaved) do firm = Firm.new firm.plain_clients.create :name=>"Whoever" end end def test_create_with_bang_on_has_many_raises_when_record_not_saved - assert_raises(ActiveRecord::RecordInvalid) do + assert_raise(ActiveRecord::RecordInvalid) do firm = Firm.find(:first) firm.plain_clients.create! end end def test_create_with_bang_on_habtm_when_parent_is_new_raises - assert_raises(ActiveRecord::RecordNotSaved) do + assert_raise(ActiveRecord::RecordNotSaved) do Developer.new("name" => "Aredridel").projects.create! end end def test_adding_a_mismatch_class - assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil } - assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 } - assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) } + assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil } + assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 } + assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) } end def test_adding_a_collection @@ -702,7 +702,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_invalid_belongs_to_dependent_option_raises_exception - assert_raises ArgumentError do + assert_raise ArgumentError do Author.belongs_to :special_author_address, :dependent => :nullify end end @@ -728,13 +728,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase def test_deleting_type_mismatch david = Developer.find(1) david.projects.reload - assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) } + assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) } end def test_deleting_self_type_mismatch david = Developer.find(1) david.projects.reload - assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) } + assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) } end def test_destroy_all diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 14032a6..24ce080 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -59,8 +59,8 @@ class HasOneAssociationsTest < ActiveRecord::TestCase end def test_type_mismatch - assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 } - assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) } + assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 } + assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) } end def test_natural_assignment @@ -76,7 +76,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase companies(:first_firm).save assert_nil companies(:first_firm).account # account is dependent, therefore is destroyed when reference to owner is lost - assert_raises(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } + assert_raise(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } end def test_natural_assignment_to_already_associated_record @@ -350,8 +350,8 @@ class HasOneAssociationsTest < ActiveRecord::TestCase end def test_has_one_proxy_should_not_respond_to_private_methods - assert_raises(NoMethodError) { accounts(:signals37).private_method } - assert_raises(NoMethodError) { companies(:first_firm).account.private_method } + assert_raise(NoMethodError) { accounts(:signals37).private_method } + assert_raise(NoMethodError) { companies(:first_firm).account.private_method } end def test_has_one_proxy_should_respond_to_private_methods_via_send diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb index f65d76e..f96b555 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -115,8 +115,8 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase end def test_has_one_through_proxy_should_not_respond_to_private_methods - assert_raises(NoMethodError) { clubs(:moustache_club).private_method } - assert_raises(NoMethodError) { @member.club.private_method } + assert_raise(NoMethodError) { clubs(:moustache_club).private_method } + assert_raise(NoMethodError) { @member.club.private_method } end def test_has_one_through_proxy_should_respond_to_private_methods_via_send diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 77ee8d8..9e89884 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -88,7 +88,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase %w(save create_or_update).each do |method| klass = Class.new ActiveRecord::Base klass.class_eval "def #{method}() 'defined #{method}' end" - assert_raises ActiveRecord::DangerousAttributeError do + assert_raise ActiveRecord::DangerousAttributeError do klass.instance_method_already_implemented?(method) end end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 0f03dae..cecc267 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -424,8 +424,8 @@ class BasicsTest < ActiveRecord::TestCase def test_non_attribute_access_and_assignment topic = Topic.new assert !topic.respond_to?("mumbo") - assert_raises(NoMethodError) { topic.mumbo } - assert_raises(NoMethodError) { topic.mumbo = 5 } + assert_raise(NoMethodError) { topic.mumbo } + assert_raise(NoMethodError) { topic.mumbo = 5 } end def test_preserving_date_objects @@ -490,7 +490,7 @@ class BasicsTest < ActiveRecord::TestCase end def test_record_not_found_exception - assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) } + assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) } end def test_initialize_with_attributes @@ -841,7 +841,7 @@ class BasicsTest < ActiveRecord::TestCase client.delete assert client.frozen? assert_kind_of Firm, client.firm - assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" } + assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } end def test_destroy_new_record @@ -855,7 +855,7 @@ class BasicsTest < ActiveRecord::TestCase client.destroy assert client.frozen? assert_kind_of Firm, client.firm - assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" } + assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } end def test_update_attribute @@ -903,8 +903,8 @@ class BasicsTest < ActiveRecord::TestCase def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used topic = TopicWithProtectedContentAndAccessibleAuthorName.new - assert_raises(RuntimeError) { topic.attributes = { "author_name" => "me" } } - assert_raises(RuntimeError) { topic.attributes = { "content" => "stuff" } } + assert_raise(RuntimeError) { topic.attributes = { "author_name" => "me" } } + assert_raise(RuntimeError) { topic.attributes = { "content" => "stuff" } } end def test_mass_assignment_protection @@ -942,7 +942,7 @@ class BasicsTest < ActiveRecord::TestCase def test_mass_assigning_invalid_attribute firm = Firm.new - assert_raises(ActiveRecord::UnknownAttributeError) do + assert_raise(ActiveRecord::UnknownAttributeError) do firm.attributes = { "id" => 5, "type" => "Client", "i_dont_even_exist" => 20 } end end @@ -1395,7 +1395,7 @@ class BasicsTest < ActiveRecord::TestCase end def test_sql_injection_via_find - assert_raises(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do Topic.find("123456 OR id > 0") end end diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 080f6a7..82f161c 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -249,8 +249,8 @@ class CalculationsTest < ActiveRecord::TestCase Company.send(:validate_calculation_options, :count, :include => true) end - assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) } - assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) } + assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) } + assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) } end def test_should_count_selected_field_with_include diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb index 11830a2..0fb0af4 100644 --- a/activerecord/test/cases/callbacks_test.rb +++ b/activerecord/test/cases/callbacks_test.rb @@ -342,13 +342,13 @@ class CallbacksTest < ActiveRecord::TestCase david = ImmutableDeveloper.find(1) assert david.valid? assert !david.save - assert_raises(ActiveRecord::RecordNotSaved) { david.save! } + assert_raise(ActiveRecord::RecordNotSaved) { david.save! } david = ImmutableDeveloper.find(1) david.salary = 10_000_000 assert !david.valid? assert !david.save - assert_raises(ActiveRecord::RecordInvalid) { david.save! } + assert_raise(ActiveRecord::RecordInvalid) { david.save! } end def test_before_create_returning_false diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index 10cdbdc..00e805c 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -204,7 +204,7 @@ class DirtyTest < ActiveRecord::TestCase pirate = Pirate.new pirate.parrot_id = 1 - assert_raises(ActiveRecord::RecordInvalid) { pirate.save! } + assert_raise(ActiveRecord::RecordInvalid) { pirate.save! } check_pirate_after_save_failure(pirate) end diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index d4d770b..9b70e76 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -137,7 +137,7 @@ class FinderTest < ActiveRecord::TestCase end def test_find_by_ids_missing_one - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) } end def test_find_all_with_limit @@ -220,7 +220,7 @@ class FinderTest < ActiveRecord::TestCase end def test_unexisting_record_exception_handling - assert_raises(ActiveRecord::RecordNotFound) { + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1).parent } @@ -229,7 +229,7 @@ class FinderTest < ActiveRecord::TestCase def test_find_only_some_columns topic = Topic.find(1, :select => "author_name") - assert_raises(ActiveRecord::MissingAttributeError) {topic.title} + assert_raise(ActiveRecord::MissingAttributeError) {topic.title} assert_equal "David", topic.author_name assert !topic.attribute_present?("title") #assert !topic.respond_to?("title") @@ -251,22 +251,22 @@ class FinderTest < ActiveRecord::TestCase def test_find_on_array_conditions assert Topic.find(1, :conditions => ["approved = ?", false]) - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) } end def test_find_on_hash_conditions assert Topic.find(1, :conditions => { :approved => false }) - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) } end def test_find_on_hash_conditions_with_explicit_table_name assert Topic.find(1, :conditions => { 'topics.approved' => false }) - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) } end def test_find_on_hash_conditions_with_hashed_table_name assert Topic.find(1, :conditions => {:topics => { :approved => false }}) - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) } end def test_find_with_hash_conditions_on_joined_table @@ -284,7 +284,7 @@ class FinderTest < ActiveRecord::TestCase def test_find_on_hash_conditions_with_explicit_table_name_and_aggregate david = customers(:david) assert Customer.find(david.id, :conditions => { 'customers.name' => david.name, :address => david.address }) - assert_raises(ActiveRecord::RecordNotFound) { + assert_raise(ActiveRecord::RecordNotFound) { Customer.find(david.id, :conditions => { 'customers.name' => david.name + "1", :address => david.address }) } end @@ -295,7 +295,7 @@ class FinderTest < ActiveRecord::TestCase def test_find_on_hash_conditions_with_range assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1..2 }).map(&:id).sort - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) } end def test_find_on_hash_conditions_with_multiple_ranges @@ -305,9 +305,9 @@ class FinderTest < ActiveRecord::TestCase def test_find_on_multiple_hash_conditions assert Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => false }) - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) } - assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } end def test_condition_interpolation @@ -331,7 +331,7 @@ class FinderTest < ActiveRecord::TestCase end def test_hash_condition_find_malformed - assert_raises(ActiveRecord::StatementInvalid) { + assert_raise(ActiveRecord::StatementInvalid) { Company.find(:first, :conditions => { :id => 2, :dhh => true }) } end @@ -400,10 +400,10 @@ class FinderTest < ActiveRecord::TestCase assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!"]) assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!' OR 1=1"]) assert_kind_of Time, Topic.find(:first, :conditions => ["id = ?", 1]).written_on - assert_raises(ActiveRecord::PreparedStatementInvalid) { + assert_raise(ActiveRecord::PreparedStatementInvalid) { Company.find(:first, :conditions => ["id=? AND name = ?", 2]) } - assert_raises(ActiveRecord::PreparedStatementInvalid) { + assert_raise(ActiveRecord::PreparedStatementInvalid) { Company.find(:first, :conditions => ["id=?", 2, 3, 4]) } end @@ -420,11 +420,11 @@ class FinderTest < ActiveRecord::TestCase def test_bind_arity assert_nothing_raised { bind '' } - assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '', 1 } + assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '', 1 } - assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '?' } + assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?' } assert_nothing_raised { bind '?', 1 } - assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 } + assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 } end def test_named_bind_variables @@ -531,7 +531,7 @@ class FinderTest < ActiveRecord::TestCase def test_find_by_one_attribute_bang assert_equal topics(:first), Topic.find_by_title!("The First Topic") - assert_raises(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") } end def test_find_by_one_attribute_caches_dynamic_finder @@ -612,14 +612,14 @@ class FinderTest < ActiveRecord::TestCase end def test_find_by_one_missing_attribute - assert_raises(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } + assert_raise(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } end def test_find_by_invalid_method_syntax - assert_raises(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") } - assert_raises(NoMethodError) { Topic.find_by_title?("The First Topic") } - assert_raises(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") } - assert_raises(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") } + assert_raise(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") } + assert_raise(NoMethodError) { Topic.find_by_title?("The First Topic") } + assert_raise(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") } + assert_raise(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") } end def test_find_by_two_attributes @@ -641,8 +641,8 @@ class FinderTest < ActiveRecord::TestCase end def test_find_last_by_invalid_method_syntax - assert_raises(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") } - assert_raises(NoMethodError) { Topic.find_last_by_title?("The First Topic") } + assert_raise(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") } + assert_raise(NoMethodError) { Topic.find_last_by_title?("The First Topic") } end def test_find_last_by_one_attribute_with_several_options @@ -650,7 +650,7 @@ class FinderTest < ActiveRecord::TestCase end def test_find_last_by_one_missing_attribute - assert_raises(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") } + assert_raise(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") } end def test_find_last_by_two_attributes @@ -903,16 +903,16 @@ class FinderTest < ActiveRecord::TestCase end def test_find_with_bad_sql - assert_raises(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" } + assert_raise(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" } end def test_find_with_invalid_params - assert_raises(ArgumentError) { Topic.find :first, :join => "It should be `joins'" } - assert_raises(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" } + assert_raise(ArgumentError) { Topic.find :first, :join => "It should be `joins'" } + assert_raise(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" } end def test_dynamic_finder_with_invalid_params - assert_raises(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" } + assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" } end def test_find_all_with_limit diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index ed2915b..f0980c3 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -151,7 +151,7 @@ class FixturesTest < ActiveRecord::TestCase end def test_dirty_dirty_yaml_file - assert_raises(Fixture::FormatError) do + assert_raise(Fixture::FormatError) do Fixtures.new( Account.connection, "courses", 'Course', FIXTURES_ROOT + "/naked/yml/courses") end end @@ -422,7 +422,7 @@ class InvalidTableNameFixturesTest < ActiveRecord::TestCase self.use_transactional_fixtures = false def test_raises_error - assert_raises FixtureClassNotFound do + assert_raise FixtureClassNotFound do funny_jokes(:a_joke) end end diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index 3f59eb9..eae5a60 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -68,7 +68,7 @@ class InheritanceTest < ActiveRecord::TestCase if current_adapter?(:SybaseAdapter) Company.connection.execute "SET IDENTITY_INSERT companies OFF" end - assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) } + assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) } end def test_inheritance_find @@ -124,7 +124,7 @@ class InheritanceTest < ActiveRecord::TestCase end def test_finding_incorrect_type_data - assert_raises(ActiveRecord::RecordNotFound) { Firm.find(2) } + assert_raise(ActiveRecord::RecordNotFound) { Firm.find(2) } assert_nothing_raised { Firm.find(1) } end diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 077cac7..8d2059d 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -35,7 +35,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end def test_lock_repeating @@ -50,9 +50,9 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } p2.first_name = 'sue2' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end def test_lock_new @@ -71,7 +71,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end def test_lock_new_with_nil @@ -95,7 +95,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, t2.version t2.tps_report_number = 800 - assert_raises(ActiveRecord::StaleObjectError) { t2.save! } + assert_raise(ActiveRecord::StaleObjectError) { t2.save! } end def test_lock_column_is_mass_assignable diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 2ec3d40..6b6886c 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -111,7 +111,7 @@ if ActiveRecord::Base.connection.supports_migrations? end end - assert_raises(ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::StatementInvalid) do Person.connection.execute "insert into testings (foo) values (NULL)" end ensure @@ -280,7 +280,7 @@ if ActiveRecord::Base.connection.supports_migrations? end Person.connection.add_column :testings, :bar, :string, :null => false - assert_raises(ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::StatementInvalid) do Person.connection.execute "insert into testings (foo, bar) values ('hello', NULL)" end ensure @@ -299,7 +299,7 @@ if ActiveRecord::Base.connection.supports_migrations? Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter) assert_nothing_raised {Person.connection.add_column :testings, :bar, :string, :null => false, :default => "default" } - assert_raises(ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::StatementInvalid) do unless current_adapter?(:OpenBaseAdapter) Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)" else @@ -547,7 +547,7 @@ if ActiveRecord::Base.connection.supports_migrations? else ActiveRecord::ActiveRecordError end - assert_raises(exception) do + assert_raise(exception) do Person.connection.rename_column "hats", "nonexistent", "should_fail" end ensure @@ -797,7 +797,7 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal "hello world", Reminder.find(:first).content WeNeedReminders.down - assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) } + assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } end def test_add_table_with_decimals @@ -858,7 +858,7 @@ if ActiveRecord::Base.connection.supports_migrations? end GiveMeBigNumbers.down - assert_raises(ActiveRecord::StatementInvalid) { BigNumber.find(:first) } + assert_raise(ActiveRecord::StatementInvalid) { BigNumber.find(:first) } end def test_migrator @@ -878,7 +878,7 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal 0, ActiveRecord::Migrator.current_version Person.reset_column_information assert !Person.column_methods_hash.include?(:last_name) - assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) } + assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } end def test_migrator_one_up @@ -934,7 +934,7 @@ if ActiveRecord::Base.connection.supports_migrations? def test_migrator_one_up_with_exception_and_rollback assert !Person.column_methods_hash.include?(:last_name) - e = assert_raises(StandardError) do + e = assert_raise(StandardError) do ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100) end @@ -1109,7 +1109,7 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal "hello world", Reminder.find(:first).content WeNeedReminders.down - assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) } + assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } ensure ActiveRecord::Base.table_name_prefix = '' ActiveRecord::Base.table_name_suffix = '' @@ -1139,13 +1139,13 @@ if ActiveRecord::Base.connection.supports_migrations? end def test_migrator_with_duplicates - assert_raises(ActiveRecord::DuplicateMigrationVersionError) do + assert_raise(ActiveRecord::DuplicateMigrationVersionError) do ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate", nil) end end def test_migrator_with_duplicate_names - assert_raises(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do + assert_raise(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate_names", nil) end end @@ -1161,7 +1161,7 @@ if ActiveRecord::Base.connection.supports_migrations? # table name is 29 chars, the standard sequence name will # be 33 chars and fail - assert_raises(ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::StatementInvalid) do begin Person.connection.create_table :table_with_name_thats_just_ok do |t| t.column :foo, :string, :null => false @@ -1188,7 +1188,7 @@ if ActiveRecord::Base.connection.supports_migrations? end # confirm the custom sequence got dropped - assert_raises(ActiveRecord::StatementInvalid) do + assert_raise(ActiveRecord::StatementInvalid) do Person.connection.execute("select suitably_short_seq.nextval from dual") end end diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index b12ec36..78454ad 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -249,7 +249,7 @@ class TransactionTest < ActiveRecord::TestCase # Test now inside a transaction: add_column should raise a StatementInvalid Topic.transaction do - assert_raises(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) } + assert_raise(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) } raise ActiveRecord::Rollback end end diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 380d8ac..15011d1 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -113,8 +113,8 @@ class ValidationsTest < ActiveRecord::TestCase end def test_invalid_record_exception - assert_raises(ActiveRecord::RecordInvalid) { Reply.create! } - assert_raises(ActiveRecord::RecordInvalid) { Reply.new.save! } + assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } + assert_raise(ActiveRecord::RecordInvalid) { Reply.new.save! } begin r = Reply.new @@ -126,13 +126,13 @@ class ValidationsTest < ActiveRecord::TestCase end def test_exception_on_create_bang_many - assert_raises(ActiveRecord::RecordInvalid) do + assert_raise(ActiveRecord::RecordInvalid) do Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }]) end end def test_exception_on_create_bang_with_block - assert_raises(ActiveRecord::RecordInvalid) do + assert_raise(ActiveRecord::RecordInvalid) do Reply.create!({ "title" => "OK" }) do |r| r.content = nil end @@ -140,7 +140,7 @@ class ValidationsTest < ActiveRecord::TestCase end def test_exception_on_create_bang_many_with_block - assert_raises(ActiveRecord::RecordInvalid) do + assert_raise(ActiveRecord::RecordInvalid) do Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r| r.content = nil end @@ -149,7 +149,7 @@ class ValidationsTest < ActiveRecord::TestCase def test_scoped_create_without_attributes Reply.with_scope(:create => {}) do - assert_raises(ActiveRecord::RecordInvalid) { Reply.create! } + assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } end end diff --git a/activeresource/test/authorization_test.rb b/activeresource/test/authorization_test.rb index ead7f5c..ca25f43 100644 --- a/activeresource/test/authorization_test.rb +++ b/activeresource/test/authorization_test.rb @@ -107,10 +107,10 @@ class AuthorizationTest < Test::Unit::TestCase end def test_raises_invalid_request_on_unauthorized_requests - assert_raises(ActiveResource::InvalidRequestError) { @conn.post("/people/2.xml") } - assert_raises(ActiveResource::InvalidRequestError) { @conn.post("/people/2/addresses.xml") } - assert_raises(ActiveResource::InvalidRequestError) { @conn.put("/people/2.xml") } - assert_raises(ActiveResource::InvalidRequestError) { @conn.delete("/people/2.xml") } + assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2.xml") } + assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2/addresses.xml") } + assert_raise(ActiveResource::InvalidRequestError) { @conn.put("/people/2.xml") } + assert_raise(ActiveResource::InvalidRequestError) { @conn.delete("/people/2.xml") } end protected diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index d37a6d4..41d24cc 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -564,14 +564,14 @@ class BaseTest < Test::Unit::TestCase def test_custom_header Person.headers['key'] = 'value' - assert_raises(ActiveResource::ResourceNotFound) { Person.find(4) } + assert_raise(ActiveResource::ResourceNotFound) { Person.find(4) } ensure Person.headers.delete('key') end def test_find_by_id_not_found - assert_raises(ActiveResource::ResourceNotFound) { Person.find(99) } - assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1) } + assert_raise(ActiveResource::ResourceNotFound) { Person.find(99) } + assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1) } end def test_find_all_by_from @@ -684,7 +684,7 @@ class BaseTest < Test::Unit::TestCase ActiveResource::HttpMock.respond_to do |mock| mock.post "/people.xml", {}, nil, 409 end - assert_raises(ActiveResource::ResourceConflict) { Person.create(:name => 'Rick') } + assert_raise(ActiveResource::ResourceConflict) { Person.create(:name => 'Rick') } end def test_clone @@ -713,7 +713,7 @@ class BaseTest < Test::Unit::TestCase matz.non_ar_arr = ["not", "ARes"] matz_c = matz.clone assert matz_c.new? - assert_raises(NoMethodError) {matz_c.address} + assert_raise(NoMethodError) {matz_c.address} assert_equal matz.non_ar_hash, matz_c.non_ar_hash assert_equal matz.non_ar_arr, matz_c.non_ar_arr @@ -751,7 +751,7 @@ class BaseTest < Test::Unit::TestCase mock.get "/people/2.xml", {}, @david mock.put "/people/2.xml", @default_request_headers, nil, 409 end - assert_raises(ActiveResource::ResourceConflict) { Person.find(2).save } + assert_raise(ActiveResource::ResourceConflict) { Person.find(2).save } end def test_destroy @@ -759,7 +759,7 @@ class BaseTest < Test::Unit::TestCase ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1.xml", {}, nil, 404 end - assert_raises(ActiveResource::ResourceNotFound) { Person.find(1).destroy } + assert_raise(ActiveResource::ResourceNotFound) { Person.find(1).destroy } end def test_destroy_with_custom_prefix @@ -767,7 +767,7 @@ class BaseTest < Test::Unit::TestCase ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1/addresses/1.xml", {}, nil, 404 end - assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } + assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } end def test_delete @@ -775,7 +775,7 @@ class BaseTest < Test::Unit::TestCase ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1.xml", {}, nil, 404 end - assert_raises(ActiveResource::ResourceNotFound) { Person.find(1) } + assert_raise(ActiveResource::ResourceNotFound) { Person.find(1) } end def test_delete_with_custom_prefix @@ -783,7 +783,7 @@ class BaseTest < Test::Unit::TestCase ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1/addresses/1.xml", {}, nil, 404 end - assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } + assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } end def test_exists diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb b/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb index bbb35ec..50d6832 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb @@ -116,10 +116,10 @@ class I18nTest < Test::Unit::TestCase end def test_localize_nil_raises_argument_error - assert_raises(I18n::ArgumentError) { I18n.l nil } + assert_raise(I18n::ArgumentError) { I18n.l nil } end def test_localize_object_raises_argument_error - assert_raises(I18n::ArgumentError) { I18n.l Object.new } + assert_raise(I18n::ArgumentError) { I18n.l Object.new } end end diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb b/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb index e181975..6cce98b 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb @@ -145,7 +145,7 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase end def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data - assert_raises I18n::MissingTranslationData do + assert_raise I18n::MissingTranslationData do @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3]) end end @@ -170,11 +170,11 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase end def test_translate_given_nil_as_a_locale_raises_an_argument_error - assert_raises(I18n::InvalidLocale){ @backend.translate nil, :bar } + assert_raise(I18n::InvalidLocale){ @backend.translate nil, :bar } end def test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data - assert_raises(I18n::MissingTranslationData){ @backend.translate 'de', :bogus } + assert_raise(I18n::MissingTranslationData){ @backend.translate 'de', :bogus } end end @@ -220,15 +220,15 @@ class I18nSimpleBackendPluralizeTest < Test::Unit::TestCase end def test_interpolate_given_incomplete_pluralization_data_raises_invalid_pluralization_data - assert_raises(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, {:one => 'bar'}, 2) } + assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, {:one => 'bar'}, 2) } end # def test_interpolate_given_a_string_raises_invalid_pluralization_data - # assert_raises(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, 'bar', 2) } + # assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, 'bar', 2) } # end # # def test_interpolate_given_an_array_raises_invalid_pluralization_data - # assert_raises(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, ['bar'], 2) } + # assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, ['bar'], 2) } # end end @@ -256,11 +256,11 @@ class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase end def test_interpolate_given_an_empty_values_hash_raises_missing_interpolation_argument - assert_raises(I18n::MissingInterpolationArgument) { @backend.send(:interpolate, nil, 'Hi {{name}}!', {}) } + assert_raise(I18n::MissingInterpolationArgument) { @backend.send(:interpolate, nil, 'Hi {{name}}!', {}) } end def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key - assert_raises(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) } + assert_raise(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) } end end @@ -310,11 +310,11 @@ class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase end def test_localize_nil_raises_argument_error - assert_raises(I18n::ArgumentError) { @backend.localize 'de', nil } + assert_raise(I18n::ArgumentError) { @backend.localize 'de', nil } end def test_localize_object_raises_argument_error - assert_raises(I18n::ArgumentError) { @backend.localize 'de', Object.new } + assert_raise(I18n::ArgumentError) { @backend.localize 'de', Object.new } end end @@ -444,7 +444,7 @@ class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase include I18nSimpleBackendTestSetup def test_load_translations_with_unknown_file_type_raises_exception - assert_raises(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" } + assert_raise(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" } end def test_load_translations_with_ruby_file_type_does_not_raise_exception diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb index 9c6071d..48d8a78 100644 --- a/activesupport/test/core_ext/class_test.rb +++ b/activesupport/test/core_ext/class_test.rb @@ -19,19 +19,19 @@ class ClassTest < Test::Unit::TestCase def test_removing_class_in_root_namespace assert A.is_a?(Class) Class.remove_class(A) - assert_raises(NameError) { A.is_a?(Class) } + assert_raise(NameError) { A.is_a?(Class) } end def test_removing_class_in_one_level_namespace assert X::B.is_a?(Class) Class.remove_class(X::B) - assert_raises(NameError) { X::B.is_a?(Class) } + assert_raise(NameError) { X::B.is_a?(Class) } end def test_removing_class_in_two_level_namespace assert Y::Z::C.is_a?(Class) Class.remove_class(Y::Z::C) - assert_raises(NameError) { Y::Z::C.is_a?(Class) } + assert_raise(NameError) { Y::Z::C.is_a?(Class) } end def test_retrieving_subclasses diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index b63ab30..f1f1f15 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -234,7 +234,7 @@ class HashExtTest < Test::Unit::TestCase { :failure => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny) end - assert_raises(ArgumentError, "Unknown key(s): failore") do + assert_raise(ArgumentError, "Unknown key(s): failore") do { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) { :failore => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny) end @@ -884,7 +884,7 @@ class QueryTest < Test::Unit::TestCase end def test_expansion_count_is_limited - assert_raises RuntimeError do + assert_raise RuntimeError do attack_xml = <<-EOT :mutex - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do @target.synchronize :to_s, :with => :mutex end end diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index a5d9850..0d3d10f 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -92,8 +92,8 @@ class ModuleTest < Test::Unit::TestCase end def test_missing_delegation_target - assert_raises(ArgumentError) { eval($nowhere) } - assert_raises(ArgumentError) { eval($noplace) } + assert_raise(ArgumentError) { eval($nowhere) } + assert_raise(ArgumentError) { eval($noplace) } end def test_delegation_prefix @@ -141,7 +141,7 @@ class ModuleTest < Test::Unit::TestCase def test_delegation_without_allow_nil_and_nil_value david = Someone.new("David") - assert_raises(NoMethodError) { david.street } + assert_raise(NoMethodError) { david.street } end def test_parent @@ -314,7 +314,7 @@ class MethodAliasingTest < Test::Unit::TestCase alias_method_chain :duck, :orange end - assert_raises NoMethodError do + assert_raise NoMethodError do @instance.duck end @@ -330,7 +330,7 @@ class MethodAliasingTest < Test::Unit::TestCase alias_method_chain :duck, :orange end - assert_raises NoMethodError do + assert_raise NoMethodError do @instance.duck end diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 2f79b6f..f4c08aa 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -109,7 +109,7 @@ end class ObjectTests < Test::Unit::TestCase def test_suppress_re_raises - assert_raises(LoadError) { suppress(ArgumentError) {raise LoadError} } + assert_raise(LoadError) { suppress(ArgumentError) {raise LoadError} } end def test_suppress_supresses suppress(ArgumentError) { raise ArgumentError } diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index dc36336..bd76efc 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -813,7 +813,7 @@ class TimeWithZoneMethodsForTimeAndDateTimeTest < Test::Unit::TestCase def test_use_zone_with_exception_raised Time.zone = 'Alaska' - assert_raises RuntimeError do + assert_raise RuntimeError do Time.use_zone('Hawaii') { raise RuntimeError } end assert_equal ActiveSupport::TimeZone['Alaska'], Time.zone diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index fe04b91..a21f094 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -43,7 +43,7 @@ class DependenciesTest < Test::Unit::TestCase end def test_missing_dependency_raises_missing_source_file - assert_raises(MissingSourceFile) { require_dependency("missing_service") } + assert_raise(MissingSourceFile) { require_dependency("missing_service") } end def test_missing_association_raises_nothing @@ -136,10 +136,10 @@ class DependenciesTest < Test::Unit::TestCase def test_non_existing_const_raises_name_error with_loading 'autoloading_fixtures' do - assert_raises(NameError) { DoesNotExist } - assert_raises(NameError) { NoModule::DoesNotExist } - assert_raises(NameError) { A::DoesNotExist } - assert_raises(NameError) { A::B::DoesNotExist } + assert_raise(NameError) { DoesNotExist } + assert_raise(NameError) { NoModule::DoesNotExist } + assert_raise(NameError) { A::DoesNotExist } + assert_raise(NameError) { A::B::DoesNotExist } end end @@ -206,8 +206,8 @@ class DependenciesTest < Test::Unit::TestCase def failing_test_access_thru_and_upwards_fails with_loading 'autoloading_fixtures' do assert ! defined?(ModuleFolder) - assert_raises(NameError) { ModuleFolder::Object } - assert_raises(NameError) { ModuleFolder::NestedClass::Object } + assert_raise(NameError) { ModuleFolder::Object } + assert_raise(NameError) { ModuleFolder::NestedClass::Object } Object.__send__ :remove_const, :ModuleFolder end end @@ -382,7 +382,7 @@ class DependenciesTest < Test::Unit::TestCase with_loading 'autoloading_fixtures' do require_dependency '././counting_loader' assert_equal 1, $counting_loaded_times - assert_raises(ArgumentError) { ActiveSupport::Dependencies.load_missing_constant Object, :CountingLoader } + assert_raise(ArgumentError) { ActiveSupport::Dependencies.load_missing_constant Object, :CountingLoader } assert_equal 1, $counting_loaded_times end end @@ -421,7 +421,7 @@ class DependenciesTest < Test::Unit::TestCase def test_nested_load_error_isnt_rescued with_loading 'dependencies' do - assert_raises(MissingSourceFile) do + assert_raise(MissingSourceFile) do RequiresNonexistent1 end end @@ -494,7 +494,7 @@ class DependenciesTest < Test::Unit::TestCase def test_unloadable_should_fail_with_anonymous_modules with_loading 'autoloading_fixtures' do m = Module.new - assert_raises(ArgumentError) { m.unloadable } + assert_raise(ArgumentError) { m.unloadable } end end @@ -584,7 +584,7 @@ class DependenciesTest < Test::Unit::TestCase end def test_new_constants_in_with_illegal_module_name_raises_correct_error - assert_raises(NameError) do + assert_raise(NameError) do ActiveSupport::Dependencies.new_constants_in("Illegal-Name") {} end end diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index d8c93dc..948b6d9 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -161,13 +161,13 @@ class InflectorTest < Test::Unit::TestCase assert_nothing_raised { assert_equal Ace::Base::Case, ActiveSupport::Inflector.constantize("::Ace::Base::Case") } assert_nothing_raised { assert_equal InflectorTest, ActiveSupport::Inflector.constantize("InflectorTest") } assert_nothing_raised { assert_equal InflectorTest, ActiveSupport::Inflector.constantize("::InflectorTest") } - assert_raises(NameError) { ActiveSupport::Inflector.constantize("UnknownClass") } - assert_raises(NameError) { ActiveSupport::Inflector.constantize("An invalid string") } - assert_raises(NameError) { ActiveSupport::Inflector.constantize("InvalidClass\n") } + assert_raise(NameError) { ActiveSupport::Inflector.constantize("UnknownClass") } + assert_raise(NameError) { ActiveSupport::Inflector.constantize("An invalid string") } + assert_raise(NameError) { ActiveSupport::Inflector.constantize("InvalidClass\n") } end def test_constantize_does_lexical_lookup - assert_raises(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") } + assert_raise(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") } end def test_ordinal diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 19ae3a0..ec11fdc 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -36,6 +36,6 @@ class TestJSONDecoding < Test::Unit::TestCase end def test_failed_json_decoding - assert_raises(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) } + assert_raise(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) } end end diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb index 8ed21cc..8fda7af 100644 --- a/activesupport/test/json/encoding_test.rb +++ b/activesupport/test/json/encoding_test.rb @@ -75,7 +75,7 @@ class TestJSONEncoding < Test::Unit::TestCase def test_exception_raised_when_encoding_circular_reference a = [1] a << a - assert_raises(ActiveSupport::JSON::CircularReferenceError) { a.to_json } + assert_raise(ActiveSupport::JSON::CircularReferenceError) { a.to_json } end def test_hash_key_identifiers_are_always_quoted diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index c0b4a46..ed34615 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -33,7 +33,7 @@ class MessageEncryptorTest < Test::Unit::TestCase private def assert_not_decrypted(value) - assert_raises(ActiveSupport::MessageEncryptor::InvalidMessage) do + assert_raise(ActiveSupport::MessageEncryptor::InvalidMessage) do @encryptor.decrypt(value) end end diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index 2190308..57c4ce8 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -18,7 +18,7 @@ class MessageVerifierTest < Test::Unit::TestCase end def assert_not_verified(message) - assert_raises(ActiveSupport::MessageVerifier::InvalidSignature) do + assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do @verifier.verify(message) end end diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index 067c461..b0fec08 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -26,7 +26,7 @@ class MultibyteCharsTest < Test::Unit::TestCase assert_nothing_raised do @chars.__method_for_multibyte_testing end - assert_raises NoMethodError do + assert_raise NoMethodError do @chars.__unknown_method end end @@ -71,7 +71,7 @@ class MultibyteCharsTest < Test::Unit::TestCase end def test_unpack_raises_encoding_error_on_broken_strings - assert_raises(ActiveSupport::Multibyte::EncodingError) do + assert_raise(ActiveSupport::Multibyte::EncodingError) do @proxy_class.u_unpack(BYTE_STRING) end end @@ -214,8 +214,8 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase end def test_insert_throws_index_error - assert_raises(IndexError) { @chars.insert(-12, 'わ')} - assert_raises(IndexError) { @chars.insert(12, 'わ') } + assert_raise(IndexError) { @chars.insert(-12, 'わ')} + assert_raise(IndexError) { @chars.insert(12, 'わ') } end def test_should_know_if_one_includes_the_other @@ -227,7 +227,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase end def test_include_raises_type_error_when_nil_is_passed - assert_raises(TypeError) do + assert_raise(TypeError) do @chars.include?(nil) end end @@ -262,22 +262,22 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase def test_indexed_insert_should_raise_on_index_overflow before = @chars.to_s - assert_raises(IndexError) { @chars[10] = 'a' } - assert_raises(IndexError) { @chars[10, 4] = 'a' } - assert_raises(IndexError) { @chars[/ii/] = 'a' } - assert_raises(IndexError) { @chars[/()/, 10] = 'a' } + assert_raise(IndexError) { @chars[10] = 'a' } + assert_raise(IndexError) { @chars[10, 4] = 'a' } + assert_raise(IndexError) { @chars[/ii/] = 'a' } + assert_raise(IndexError) { @chars[/()/, 10] = 'a' } assert_equal before, @chars end def test_indexed_insert_should_raise_on_range_overflow before = @chars.to_s - assert_raises(RangeError) { @chars[10..12] = 'a' } + assert_raise(RangeError) { @chars[10..12] = 'a' } assert_equal before, @chars end def test_rjust_should_raise_argument_errors_on_bad_arguments - assert_raises(ArgumentError) { @chars.rjust(10, '') } - assert_raises(ArgumentError) { @chars.rjust } + assert_raise(ArgumentError) { @chars.rjust(10, '') } + assert_raise(ArgumentError) { @chars.rjust } end def test_rjust_should_count_characters_instead_of_bytes @@ -294,8 +294,8 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase end def test_ljust_should_raise_argument_errors_on_bad_arguments - assert_raises(ArgumentError) { @chars.ljust(10, '') } - assert_raises(ArgumentError) { @chars.ljust } + assert_raise(ArgumentError) { @chars.ljust(10, '') } + assert_raise(ArgumentError) { @chars.ljust } end def test_ljust_should_count_characters_instead_of_bytes @@ -312,8 +312,8 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase end def test_center_should_raise_argument_errors_on_bad_arguments - assert_raises(ArgumentError) { @chars.center(10, '') } - assert_raises(ArgumentError) { @chars.center } + assert_raise(ArgumentError) { @chars.center(10, '') } + assert_raise(ArgumentError) { @chars.center } end def test_center_should_count_charactes_instead_of_bytes @@ -436,7 +436,7 @@ class MultibyteCharsExtrasTest < Test::Unit::TestCase if RUBY_VERSION >= '1.9' def test_tidy_bytes_is_broken_on_1_9_0 - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do assert_equal_codepoints [0xfffd].pack('U'), chars("\xef\xbf\xbd").tidy_bytes end end diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb index dda7850..7f11f66 100644 --- a/activesupport/test/string_inquirer_test.rb +++ b/activesupport/test/string_inquirer_test.rb @@ -10,6 +10,6 @@ class StringInquirerTest < Test::Unit::TestCase end def test_missing_question_mark - assert_raises(NoMethodError) { ActiveSupport::StringInquirer.new("production").production } + assert_raise(NoMethodError) { ActiveSupport::StringInquirer.new("production").production } end end diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index f80575c..dfbd72a 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -268,7 +268,7 @@ class TimeZoneTest < Test::Unit::TestCase assert_nil ActiveSupport::TimeZone["bogus"] assert_instance_of ActiveSupport::TimeZone, ActiveSupport::TimeZone["Central Time (US & Canada)"] assert_instance_of ActiveSupport::TimeZone, ActiveSupport::TimeZone[8] - assert_raises(ArgumentError) { ActiveSupport::TimeZone[false] } + assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] } end def test_new diff --git a/railties/doc/guides/html/testing_rails_applications.html b/railties/doc/guides/html/testing_rails_applications.html index a94c81d..c7afa64 100644 --- a/railties/doc/guides/html/testing_rails_applications.html +++ b/railties/doc/guides/html/testing_rails_applications.html @@ -742,7 +742,7 @@ Assertion Purposeassert_no_match( regexp, string, [msg] ) Ensures that a string doesn't matches the regular expression. assert_in_delta( expecting, actual, delta, [msg] ) Ensures that the numbers expecting and actual are within delta of each other. assert_throws( symbol, [msg] ) { block } Ensures that the given block throws the symbol. -assert_raises( exception1, exception2, … ) { block } Ensures that the given block raises one of the given exceptions. +assert_raise( exception1, exception2, … ) { block } Ensures that the given block raises one of the given exceptions. assert_nothing_raised( exception1, exception2, … ) { block } Ensures that the given block doesn't raise one of the given exceptions. assert_instance_of( class, obj, [msg] ) Ensures that obj is of the class type. assert_kind_of( class, obj, [msg] ) Ensures that obj is or descends from class. diff --git a/railties/doc/guides/source/testing_rails_applications.txt b/railties/doc/guides/source/testing_rails_applications.txt index cb77829..6f6e6f1 100644 --- a/railties/doc/guides/source/testing_rails_applications.txt +++ b/railties/doc/guides/source/testing_rails_applications.txt @@ -419,7 +419,7 @@ Assertion Purpose +assert_no_match( regexp, string, [msg] )+ Ensures that a string doesn't matches the regular expression. +assert_in_delta( expecting, actual, delta, [msg] )+ Ensures that the numbers `expecting` and `actual` are within `delta` of each other. +assert_throws( symbol, [msg] ) { block }+ Ensures that the given block throws the symbol. -+assert_raises( exception1, exception2, ... ) { block }+ Ensures that the given block raises one of the given exceptions. ++assert_raise( exception1, exception2, ... ) { block }+ Ensures that the given block raises one of the given exceptions. +assert_nothing_raised( exception1, exception2, ... ) { block }+ Ensures that the given block doesn't raise one of the given exceptions. +assert_instance_of( class, obj, [msg] )+ Ensures that +obj+ is of the +class+ type. +assert_kind_of( class, obj, [msg] )+ Ensures that +obj+ is or descends from +class+. diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index dad9e55..ecf7d44 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -238,7 +238,7 @@ uses_mocha "Initializer plugin loading tests" do def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error only_load_the_following_plugins! [:stubby, :acts_as_a_non_existant_plugin] - assert_raises(LoadError) do + assert_raise(LoadError) do load_plugins! end end diff --git a/railties/test/plugin_locator_test.rb b/railties/test/plugin_locator_test.rb index 5a8c651..fde7e92 100644 --- a/railties/test/plugin_locator_test.rb +++ b/railties/test/plugin_locator_test.rb @@ -5,7 +5,7 @@ uses_mocha "Plugin Locator Tests" do class PluginLocatorTest < Test::Unit::TestCase def test_should_require_subclasses_to_implement_the_plugins_method - assert_raises(RuntimeError) do + assert_raise(RuntimeError) do Rails::Plugin::Locator.new(nil).plugins end end diff --git a/railties/test/plugin_test.rb b/railties/test/plugin_test.rb index 5012424..9e6e5ba 100644 --- a/railties/test/plugin_test.rb +++ b/railties/test/plugin_test.rb @@ -55,11 +55,11 @@ uses_mocha "Plugin Tests" do plugin_for(@valid_plugin_path).load_paths end - assert_raises(LoadError) do + assert_raise(LoadError) do plugin_for(@empty_plugin_path).load_paths end - assert_raises(LoadError) do + assert_raise(LoadError) do plugin_for('this_is_not_a_plugin_directory').load_paths end end @@ -80,13 +80,13 @@ uses_mocha "Plugin Tests" do end # This is an empty path so it raises - assert_raises(LoadError) do + assert_raise(LoadError) do plugin = plugin_for(@empty_plugin_path) plugin.stubs(:evaluate_init_rb) plugin.send(:load, @initializer) end - assert_raises(LoadError) do + assert_raise(LoadError) do plugin = plugin_for('this_is_not_a_plugin_directory') plugin.stubs(:evaluate_init_rb) plugin.send(:load, @initializer) @@ -100,11 +100,11 @@ uses_mocha "Plugin Tests" do end # This is an empty path so it raises - assert_raises(LoadError) do + assert_raise(LoadError) do plugin_for(@empty_plugin_path).load_paths end - assert_raises(LoadError) do + assert_raise(LoadError) do plugin_for('this_is_not_a_plugin_directory').load_paths end end -- 1.5.6.3