diff options
57 files changed, 147 insertions, 718 deletions
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index 80f323873d..207f949fe2 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -10,13 +10,6 @@ module ActionMailer end class TestCase < ActiveSupport::TestCase - - # Use AM::TestCase for the base class when describing a mailer - register_spec_type(self) do |desc| - Class === desc && desc < ActionMailer::Base - end - register_spec_type(/Mailer( ?Test)?\z/i, self) - module Behavior extend ActiveSupport::Concern diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 99c44179fd..15729bafba 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -8,7 +8,7 @@ silence_warnings do Encoding.default_external = "UTF-8" end -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'action_mailer' require 'action_mailer/test_case' diff --git a/actionmailer/test/spec_type_test.rb b/actionmailer/test/spec_type_test.rb deleted file mode 100644 index 90db59c2d2..0000000000 --- a/actionmailer/test/spec_type_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'abstract_unit' - -class NotificationMailer < ActionMailer::Base; end -class Notifications < ActionMailer::Base; end - -class SpecTypeTest < ActiveSupport::TestCase - def assert_mailer actual - assert_equal ActionMailer::TestCase, actual - end - - def refute_mailer actual - refute_equal ActionMailer::TestCase, actual - end - - def test_spec_type_resolves_for_class_constants - assert_mailer MiniTest::Spec.spec_type(NotificationMailer) - assert_mailer MiniTest::Spec.spec_type(Notifications) - end - - def test_spec_type_resolves_for_matching_strings - assert_mailer MiniTest::Spec.spec_type("WidgetMailer") - assert_mailer MiniTest::Spec.spec_type("WidgetMailerTest") - assert_mailer MiniTest::Spec.spec_type("Widget Mailer Test") - # And is not case sensitive - assert_mailer MiniTest::Spec.spec_type("widgetmailer") - assert_mailer MiniTest::Spec.spec_type("widgetmailertest") - assert_mailer MiniTest::Spec.spec_type("widget mailer test") - end - - def test_spec_type_wont_match_non_space_characters - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\tTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\rTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\nTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\fTest") - refute_mailer MiniTest::Spec.spec_type("Widget MailerXTest") - end -end diff --git a/actionmailer/test/test_test.rb b/actionmailer/test/test_test.rb index 139eb53359..86fd37bea6 100644 --- a/actionmailer/test/test_test.rb +++ b/actionmailer/test/test_test.rb @@ -26,147 +26,3 @@ class CrazyStringNameMailerTest < ActionMailer::TestCase assert_equal TestTestMailer, self.class.mailer_class end end - -describe TestTestMailer do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe TestTestMailer, :action do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe TestTestMailer do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe TestTestMailer, :action do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "TestTestMailer" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "TestTestMailerTest" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "TestTestMailer" do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "TestTestMailerTest" do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "AnotherCrazySymbolNameMailerTest" do - tests :test_test_mailer - - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "AnotherCrazyStringNameMailerTest" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy Name Mailer Test" do - tests TestTestMailer - - it "gets the mailer after setting it manually" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy Symbol Name Mailer Test" do - tests :test_test_mailer - - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy String Name Mailer Test" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "AnotherCrazySymbolNameMailerTest" do - tests :test_test_mailer - - describe "nested" do - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "AnotherCrazyStringNameMailerTest" do - tests 'test_test_mailer' - - describe "nested" do - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy Name Mailer Test" do - tests TestTestMailer - - describe "nested" do - it "gets the mailer after setting it manually" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy Symbol Name Mailer Test" do - tests :test_test_mailer - - describe "nested" do - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy String Name Mailer Test" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 7b48870090..331d15d403 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -360,13 +360,6 @@ module ActionController # # assert_redirected_to page_url(title: 'foo') class TestCase < ActiveSupport::TestCase - - # Use AC::TestCase for the base class when describing a controller - register_spec_type(self) do |desc| - Class === desc && desc < ActionController::Metal - end - register_spec_type(/Controller( ?Test)?\z/i, self) - module Behavior extend ActiveSupport::Concern include ActionDispatch::TestProcess diff --git a/actionpack/lib/action_dispatch/testing/assertions/dom.rb b/actionpack/lib/action_dispatch/testing/assertions/dom.rb index 6c61d4e61a..8f90a1223e 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/dom.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/dom.rb @@ -20,7 +20,7 @@ module ActionDispatch def assert_dom_not_equal(expected, actual, message = "") expected_dom = HTML::Document.new(expected).root actual_dom = HTML::Document.new(actual).root - refute_equal expected_dom, actual_dom + assert_not_equal expected_dom, actual_dom end end end diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 95cd89a166..1fc5933e98 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -491,9 +491,6 @@ module ActionDispatch include ActionController::TemplateAssertions include ActionDispatch::Routing::UrlFor - # Use AD::IntegrationTest for acceptance tests - register_spec_type(/(Acceptance|Integration) ?Test\z/i, self) - @@app = nil def self.app diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index a548b44780..4479da5bc4 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -30,9 +30,6 @@ module ActionView end end - # Use AV::TestCase for the base class for helpers and views - register_spec_type(/(Helper|View)( ?Test)?\z/i, self) - module Behavior extend ActiveSupport::Concern diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 95bff0a204..bbcd289886 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -15,7 +15,7 @@ silence_warnings do Encoding.default_external = "UTF-8" end -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'abstract_controller' require 'action_controller' require 'action_view' diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb index faf923e929..ebf6d224aa 100644 --- a/actionpack/test/controller/http_token_authentication_test.rb +++ b/actionpack/test/controller/http_token_authentication_test.rb @@ -111,21 +111,21 @@ class HttpTokenAuthenticationTest < ActionController::TestCase assert_equal(expected, actual) end - test "token_and_options returns correct token" do + test "token_and_options returns correct token with value after the equal sign" do token = 'rcHu+=HzSFw89Ypyhn/896A==f34' actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first expected = token assert_equal(expected, actual) end - test "token_and_options returns correct token" do + test "token_and_options returns correct token with slashes" do token = 'rcHu+\\\\"/896A' actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first expected = token assert_equal(expected, actual) end - test "token_and_options returns correct token" do + test "token_and_options returns correct token with quotes" do token = '\"quote\" pretty' actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first expected = token diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb index 20e433d1ec..3b1a07d7af 100644 --- a/actionpack/test/controller/live_stream_test.rb +++ b/actionpack/test/controller/live_stream_test.rb @@ -40,7 +40,7 @@ module ActionController def thread_locals tc.assert_equal 'aaron', Thread.current[:setting] - tc.refute_equal Thread.current.object_id, Thread.current[:originating_thread] + tc.assert_not_equal Thread.current.object_id, Thread.current[:originating_thread] response.headers['Content-Type'] = 'text/event-stream' %w{ hello world }.each do |word| diff --git a/actionpack/test/controller/spec_style_test.rb b/actionpack/test/controller/spec_style_test.rb deleted file mode 100644 index e118c584ca..0000000000 --- a/actionpack/test/controller/spec_style_test.rb +++ /dev/null @@ -1,208 +0,0 @@ -require "abstract_unit" - -class ApplicationController < ActionController::Base; end -class ModelsController < ApplicationController; end -module Admin - class WidgetsController < ApplicationController; end -end - -# ApplicationController -describe ApplicationController do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -describe ApplicationController, :index do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -describe ApplicationController, "unauthenticated user" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -describe "ApplicationControllerTest" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -describe "ApplicationControllerTest", :index do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -describe "ApplicationControllerTest", "unauthenticated user" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ApplicationController, @controller - end - end - end -end - -# ModelsController -describe ModelsController do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -describe ModelsController, :index do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -describe ModelsController, "unauthenticated user" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -describe "ModelsControllerTest" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -describe "ModelsControllerTest", :index do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -describe "ModelsControllerTest", "unauthenticated user" do - describe "nested" do - describe "even deeper" do - it "exists" do - assert_kind_of ModelsController, @controller - end - end - end -end - -# Nested Admin::WidgetsControllerTest -module Admin - class WidgetsControllerTest < ActionController::TestCase - test "exists" do - assert_kind_of Admin::WidgetsController, @controller - end - end - - describe WidgetsController do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end - end - - describe WidgetsController, "unauthenticated users" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end - end -end - -class Admin::WidgetsControllerTest < ActionController::TestCase - test "exists here too" do - assert_kind_of Admin::WidgetsController, @controller - end -end - -describe Admin::WidgetsController do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end - -describe Admin::WidgetsController, "unauthenticated users" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end - -describe "Admin::WidgetsController" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end - -describe "Admin::WidgetsControllerTest" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end - -describe "Admin::WidgetsController", "unauthenticated users" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end - -describe "Admin::WidgetsControllerTest", "unauthenticated users" do - describe "index" do - it "respond successful" do - assert_kind_of Admin::WidgetsController, @controller - end - end -end diff --git a/actionpack/test/controller/spec_type_test.rb b/actionpack/test/controller/spec_type_test.rb deleted file mode 100644 index 13be8a3405..0000000000 --- a/actionpack/test/controller/spec_type_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "abstract_unit" - -class ApplicationController < ActionController::Base; end -class ModelsController < ApplicationController; end - -class ActionControllerSpecTypeTest < ActiveSupport::TestCase - def assert_controller actual - assert_equal ActionController::TestCase, actual - end - - def refute_controller actual - refute_equal ActionController::TestCase, actual - end - - def test_spec_type_resolves_for_class_constants - assert_controller MiniTest::Spec.spec_type(ApplicationController) - assert_controller MiniTest::Spec.spec_type(ModelsController) - end - - def test_spec_type_resolves_for_matching_strings - assert_controller MiniTest::Spec.spec_type("WidgetController") - assert_controller MiniTest::Spec.spec_type("WidgetControllerTest") - assert_controller MiniTest::Spec.spec_type("Widget Controller Test") - # And is not case sensitive - assert_controller MiniTest::Spec.spec_type("widgetcontroller") - assert_controller MiniTest::Spec.spec_type("widgetcontrollertest") - assert_controller MiniTest::Spec.spec_type("widget controller test") - end - - def test_spec_type_wont_match_non_space_characters - refute_controller MiniTest::Spec.spec_type("Widget Controller\tTest") - refute_controller MiniTest::Spec.spec_type("Widget Controller\rTest") - refute_controller MiniTest::Spec.spec_type("Widget Controller\nTest") - refute_controller MiniTest::Spec.spec_type("Widget Controller\fTest") - refute_controller MiniTest::Spec.spec_type("Widget ControllerXTest") - end -end diff --git a/actionpack/test/dispatch/live_response_test.rb b/actionpack/test/dispatch/live_response_test.rb index e16f23914b..e0cfb73acf 100644 --- a/actionpack/test/dispatch/live_response_test.rb +++ b/actionpack/test/dispatch/live_response_test.rb @@ -11,7 +11,7 @@ module ActionController def test_header_merge header = @response.header.merge('Foo' => 'Bar') assert_kind_of(ActionController::Live::Response::Header, header) - refute_equal header, @response.header + assert_not_equal header, @response.header end def test_initialize_with_default_headers diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb index 3f36d4f1a9..1517f96fdc 100644 --- a/actionpack/test/dispatch/request/session_test.rb +++ b/actionpack/test/dispatch/request/session_test.rb @@ -24,7 +24,7 @@ module ActionDispatch s['foo'] = 'bar' s1 = Session.create(store, env, {}) - refute_equal s, s1 + assert_not_equal s, s1 assert_equal 'bar', s1['foo'] end diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb index a3034ce001..c058bd4909 100644 --- a/actionpack/test/dispatch/routing/inspector_test.rb +++ b/actionpack/test/dispatch/routing/inspector_test.rb @@ -1,4 +1,4 @@ -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'action_controller' require 'rails/engine' require 'action_dispatch/routing/inspector' diff --git a/actionpack/test/dispatch/session/abstract_store_test.rb b/actionpack/test/dispatch/session/abstract_store_test.rb index 8daf3d3f5e..fe1a7b4f86 100644 --- a/actionpack/test/dispatch/session/abstract_store_test.rb +++ b/actionpack/test/dispatch/session/abstract_store_test.rb @@ -42,7 +42,7 @@ module ActionDispatch as.call(@env) session1 = Request::Session.find @env - refute_equal session, session1 + assert_not_equal session, session1 assert_equal session.to_hash, session1.to_hash end diff --git a/actionpack/test/dispatch/spec_type_test.rb b/actionpack/test/dispatch/spec_type_test.rb deleted file mode 100644 index 6cd19fd333..0000000000 --- a/actionpack/test/dispatch/spec_type_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "abstract_unit" - -class SpecTypeTest < ActiveSupport::TestCase - def assert_dispatch actual - assert_equal ActionDispatch::IntegrationTest, actual - end - - def refute_dispatch actual - refute_equal ActionDispatch::IntegrationTest, actual - end - - def test_spec_type_resolves_for_matching_acceptance_strings - assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptanceTest") - assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance Test") - assert_dispatch MiniTest::Spec.spec_type("widgetacceptancetest") - assert_dispatch MiniTest::Spec.spec_type("widget acceptance test") - end - - def test_spec_type_wont_match_non_space_characters_acceptance - refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\tTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\rTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\nTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\fTest") - refute_dispatch MiniTest::Spec.spec_type("Widget AcceptanceXTest") - end - - def test_spec_type_resolves_for_matching_integration_strings - assert_dispatch MiniTest::Spec.spec_type("WidgetIntegrationTest") - assert_dispatch MiniTest::Spec.spec_type("Widget Integration Test") - assert_dispatch MiniTest::Spec.spec_type("widgetintegrationtest") - assert_dispatch MiniTest::Spec.spec_type("widget integration test") - end - - def test_spec_type_wont_match_non_space_characters_integration - refute_dispatch MiniTest::Spec.spec_type("Widget Integration\tTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Integration\rTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Integration\nTest") - refute_dispatch MiniTest::Spec.spec_type("Widget Integration\fTest") - refute_dispatch MiniTest::Spec.spec_type("Widget IntegrationXTest") - end -end diff --git a/actionpack/test/dispatch/ssl_test.rb b/actionpack/test/dispatch/ssl_test.rb index 6f075a9074..b4a39219bf 100644 --- a/actionpack/test/dispatch/ssl_test.rb +++ b/actionpack/test/dispatch/ssl_test.rb @@ -47,7 +47,7 @@ class SSLTest < ActionDispatch::IntegrationTest def test_disable_hsts_header self.app = ActionDispatch::SSL.new(default_app, :hsts => false) get "https://example.org/" - refute response.headers['Strict-Transport-Security'] + assert_not response.headers['Strict-Transport-Security'] end def test_hsts_expires diff --git a/actionpack/test/journey/gtg/transition_table_test.rb b/actionpack/test/journey/gtg/transition_table_test.rb index 6d81b72c41..133c9abe13 100644 --- a/actionpack/test/journey/gtg/transition_table_test.rb +++ b/actionpack/test/journey/gtg/transition_table_test.rb @@ -29,7 +29,7 @@ module ActionDispatch } svg = table.to_svg assert svg - refute_match(/DOCTYPE/, svg) + assert_no_match(/DOCTYPE/, svg) end end @@ -53,7 +53,7 @@ module ActionDispatch sim = simulator_for ['/foo(/bar)'] assert_match sim, '/foo' assert_match sim, '/foo/bar' - refute_match sim, '/foo/' + assert_no_match sim, '/foo/' end def test_match_data diff --git a/actionpack/test/journey/nfa/simulator_test.rb b/actionpack/test/journey/nfa/simulator_test.rb index 9f89329b57..f4fd6ec048 100644 --- a/actionpack/test/journey/nfa/simulator_test.rb +++ b/actionpack/test/journey/nfa/simulator_test.rb @@ -11,17 +11,17 @@ module ActionDispatch def test_simulate_simple_no_match sim = simulator_for ['/foo'] - refute_match sim, 'foo' + assert_no_match sim, 'foo' end def test_simulate_simple_no_match_too_long sim = simulator_for ['/foo'] - refute_match sim, '/foo/bar' + assert_no_match sim, '/foo/bar' end def test_simulate_simple_no_match_wrong_string sim = simulator_for ['/foo'] - refute_match sim, '/bar' + assert_no_match sim, '/bar' end def test_simulate_regex @@ -34,14 +34,14 @@ module ActionDispatch sim = simulator_for ['/foo', '/bar'] assert_match sim, '/bar' assert_match sim, '/foo' - refute_match sim, '/baz' + assert_no_match sim, '/baz' end def test_simulate_optional sim = simulator_for ['/foo(/bar)'] assert_match sim, '/foo' assert_match sim, '/foo/bar' - refute_match sim, '/foo/' + assert_no_match sim, '/foo/' end def test_matchdata_has_memos diff --git a/actionpack/test/journey/nodes/symbol_test.rb b/actionpack/test/journey/nodes/symbol_test.rb index f53840274a..caf797c4c6 100644 --- a/actionpack/test/journey/nodes/symbol_test.rb +++ b/actionpack/test/journey/nodes/symbol_test.rb @@ -9,7 +9,7 @@ module ActionDispatch assert sym.default_regexp? sym.regexp = nil - refute sym.default_regexp? + assert_not sym.default_regexp? end end end diff --git a/actionpack/test/journey/path/pattern_test.rb b/actionpack/test/journey/path/pattern_test.rb index 0f2d0d44c0..a42a29b4ee 100644 --- a/actionpack/test/journey/path/pattern_test.rb +++ b/actionpack/test/journey/path/pattern_test.rb @@ -88,7 +88,7 @@ module ActionDispatch path = Pattern.new strexp assert_match(path, '/page/tender') assert_match(path, '/page/love') - refute_match(path, '/page/loving') + assert_no_match(path, '/page/loving') end def test_optional_names @@ -110,7 +110,7 @@ module ActionDispatch ) path = Pattern.new strexp assert_match(path, '/123') - refute_match(path, '/') + assert_no_match(path, '/') end def test_to_regexp_with_group @@ -122,7 +122,7 @@ module ActionDispatch path = Pattern.new strexp assert_match(path, '/page/tender') assert_match(path, '/page/love') - refute_match(path, '/page/loving') + assert_no_match(path, '/page/loving') end def test_ast_sets_regular_expressions @@ -189,7 +189,7 @@ module ActionDispatch path = Pattern.new strexp assert_match(path, '/page/TENDER/aaron') assert_match(path, '/page/loVE/aaron') - refute_match(path, '/page/loVE/AAron') + assert_no_match(path, '/page/loVE/AAron') end def test_to_regexp_with_strexp @@ -210,7 +210,7 @@ module ActionDispatch path = Pattern.new '/:controller(/:action(/:id(.:format)))' uri = 'content' - refute path =~ uri + assert_not path =~ uri end def test_match_controller diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index b205db5fbc..79895e1aaf 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -92,7 +92,7 @@ module ActionDispatch routes = [specific, generic] - refute_equal specific.score(knowledge), generic.score(knowledge) + assert_not_equal specific.score(knowledge), generic.score(knowledge) found = routes.sort_by { |r| r.score(knowledge) }.last diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index 1b64600ba8..e43d415e3f 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -277,7 +277,7 @@ module ActionDispatch @router.recognize(env) do |*whatever| yielded = true end - refute yielded + assert_not yielded end def test_required_part_in_recall diff --git a/actionpack/test/journey/routes_test.rb b/actionpack/test/journey/routes_test.rb index 3b17bd53b7..017c0eaee6 100644 --- a/actionpack/test/journey/routes_test.rb +++ b/actionpack/test/journey/routes_test.rb @@ -23,7 +23,7 @@ module ActionDispatch routes.add_route nil, path, {}, {}, {} ast = routes.ast routes.add_route nil, path, {}, {}, {} - refute_equal ast, routes.ast + assert_not_equal ast, routes.ast end def test_simulator_changes @@ -33,7 +33,7 @@ module ActionDispatch routes.add_route nil, path, {}, {}, {} sim = routes.simulator routes.add_route nil, path, {}, {}, {} - refute_equal sim, routes.simulator + assert_not_equal sim, routes.simulator end def test_first_name_wins diff --git a/actionpack/test/template/spec_type_test.rb b/actionpack/test/template/spec_type_test.rb deleted file mode 100644 index 08a7bdf81d..0000000000 --- a/actionpack/test/template/spec_type_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'abstract_unit' - -class ActionViewSpecTypeTest < ActiveSupport::TestCase - def assert_view actual - assert_equal ActionView::TestCase, actual - end - - def refute_view actual - refute_equal ActionView::TestCase, actual - end - - def test_spec_type_resolves_for_matching_helper_strings - assert_view MiniTest::Spec.spec_type("WidgetHelper") - assert_view MiniTest::Spec.spec_type("WidgetHelperTest") - assert_view MiniTest::Spec.spec_type("Widget Helper Test") - # And is not case sensitive - assert_view MiniTest::Spec.spec_type("widgethelper") - assert_view MiniTest::Spec.spec_type("widgethelpertest") - assert_view MiniTest::Spec.spec_type("widget helper test") - end - - def test_spec_type_resolves_for_matching_view_strings - assert_view MiniTest::Spec.spec_type("WidgetView") - assert_view MiniTest::Spec.spec_type("WidgetViewTest") - assert_view MiniTest::Spec.spec_type("Widget View Test") - # And is not case sensitive - assert_view MiniTest::Spec.spec_type("widgetview") - assert_view MiniTest::Spec.spec_type("widgetviewtest") - assert_view MiniTest::Spec.spec_type("widget view test") - end - - def test_spec_type_wont_match_non_space_characters - refute_view MiniTest::Spec.spec_type("Widget Helper\tTest") - refute_view MiniTest::Spec.spec_type("Widget Helper\rTest") - refute_view MiniTest::Spec.spec_type("Widget Helper\nTest") - refute_view MiniTest::Spec.spec_type("Widget Helper\fTest") - refute_view MiniTest::Spec.spec_type("Widget HelperXTest") - end -end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index e843a1deb4..108a674d95 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -78,59 +78,3 @@ class CrazyStringHelperTest < ActionView::TestCase assert_equal PeopleHelper, self.class.helper_class end end - -describe PeopleHelper do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end -end - -describe PeopleHelper, :helper_class do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end -end - -describe PeopleHelper do - describe "even while nested" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end - end -end - -describe PeopleHelper, :helper_class do - describe "even while nested" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end - end -end - -describe "PeopleHelper" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end -end - -describe "PeopleHelperTest" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end -end - -describe "PeopleHelper" do - describe "even while nested" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end - end -end - -describe "PeopleHelperTest" do - describe "even while nested" do - it "resolves the right helper_class" do - assert_equal PeopleHelper, self.class.helper_class - end - end -end diff --git a/actionpack/test/ts_isolated.rb b/actionpack/test/ts_isolated.rb index c44c5d8968..55620abe84 100644 --- a/actionpack/test/ts_isolated.rb +++ b/actionpack/test/ts_isolated.rb @@ -1,4 +1,4 @@ -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'rbconfig' require 'abstract_unit' diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 7d6f11b5a5..7a63674757 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -7,4 +7,4 @@ require 'active_support/core_ext/string/access' # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true -require 'minitest/autorun' +require 'active_support/testing/autorun' diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d326ed7863..518ce9763c 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1484,7 +1484,7 @@ class BasicsTest < ActiveRecord::TestCase def test_column_types_typecast topic = Topic.first - refute_equal 't.lo', topic.author_name + assert_not_equal 't.lo', topic.author_name attrs = topic.attributes.dup attrs.delete 'id' diff --git a/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb b/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb index 1eb9bf60e1..1fd64dd0af 100644 --- a/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb +++ b/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb @@ -10,18 +10,18 @@ module ActiveRecord end def test_in_use? - refute adapter.in_use?, 'adapter is not in use' + assert_not adapter.in_use?, 'adapter is not in use' assert adapter.lease, 'lease adapter' assert adapter.in_use?, 'adapter is in use' end def test_lease_twice assert adapter.lease, 'should lease adapter' - refute adapter.lease, 'should not lease adapter' + assert_not adapter.lease, 'should not lease adapter' end def test_last_use - refute adapter.last_use + assert_not adapter.last_use adapter.lease assert adapter.last_use end @@ -30,7 +30,7 @@ module ActiveRecord assert adapter.lease, 'lease adapter' assert adapter.in_use?, 'adapter is in use' adapter.expire - refute adapter.in_use?, 'adapter is in use' + assert_not adapter.in_use?, 'adapter is in use' end def test_close @@ -44,7 +44,7 @@ module ActiveRecord # Close should put the adapter back in the pool adapter.close - refute adapter.in_use? + assert_not adapter.in_use? assert_equal adapter, pool.connection end diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 3a315d843b..5ffb32e809 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -2,8 +2,7 @@ require File.expand_path('../../../../load_paths', __FILE__) require 'config' -gem 'minitest' -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'stringio' require 'active_record' diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb index 86451289e7..4a3c48f750 100644 --- a/activerecord/test/cases/migration/change_schema_test.rb +++ b/activerecord/test/cases/migration/change_schema_test.rb @@ -293,7 +293,7 @@ module ActiveRecord end assert connection.column_exists?(:testings, :foo) - refute connection.column_exists?(:testings, :bar) + assert_not connection.column_exists?(:testings, :bar) end def test_column_exists_with_type @@ -303,10 +303,10 @@ module ActiveRecord end assert connection.column_exists?(:testings, :foo, :string) - refute connection.column_exists?(:testings, :foo, :integer) + assert_not connection.column_exists?(:testings, :foo, :integer) assert connection.column_exists?(:testings, :bar, :decimal) - refute connection.column_exists?(:testings, :bar, :integer) + assert_not connection.column_exists?(:testings, :bar, :integer) end def test_column_exists_with_definition @@ -318,13 +318,13 @@ module ActiveRecord end assert connection.column_exists?(:testings, :foo, :string, limit: 100) - refute connection.column_exists?(:testings, :foo, :string, limit: nil) + assert_not connection.column_exists?(:testings, :foo, :string, limit: nil) assert connection.column_exists?(:testings, :bar, :decimal, precision: 8, scale: 2) - refute connection.column_exists?(:testings, :bar, :decimal, precision: nil, scale: nil) + assert_not connection.column_exists?(:testings, :bar, :decimal, precision: nil, scale: nil) assert connection.column_exists?(:testings, :taggable_id, :integer, null: false) - refute connection.column_exists?(:testings, :taggable_id, :integer, null: true) + assert_not connection.column_exists?(:testings, :taggable_id, :integer, null: true) assert connection.column_exists?(:testings, :taggable_type, :string, default: 'Photo') - refute connection.column_exists?(:testings, :taggable_type, :string, default: nil) + assert_not connection.column_exists?(:testings, :taggable_type, :string, default: nil) end def test_column_exists_on_table_with_no_options_parameter_supplied diff --git a/activerecord/test/cases/migration/change_table_test.rb b/activerecord/test/cases/migration/change_table_test.rb index ac1ad176db..8065541bfe 100644 --- a/activerecord/test/cases/migration/change_table_test.rb +++ b/activerecord/test/cases/migration/change_table_test.rb @@ -1,4 +1,5 @@ require "cases/migration/helper" +require "minitest/mock" module ActiveRecord class Migration diff --git a/activerecord/test/cases/migration/column_attributes_test.rb b/activerecord/test/cases/migration/column_attributes_test.rb index b88db384a0..ec2926632c 100644 --- a/activerecord/test/cases/migration/column_attributes_test.rb +++ b/activerecord/test/cases/migration/column_attributes_test.rb @@ -16,7 +16,7 @@ module ActiveRecord end def test_add_remove_single_field_using_string_arguments - refute TestModel.column_methods_hash.key?(:last_name) + assert_not TestModel.column_methods_hash.key?(:last_name) add_column 'test_models', 'last_name', :string @@ -27,11 +27,11 @@ module ActiveRecord remove_column 'test_models', 'last_name' TestModel.reset_column_information - refute TestModel.column_methods_hash.key?(:last_name) + assert_not TestModel.column_methods_hash.key?(:last_name) end def test_add_remove_single_field_using_symbol_arguments - refute TestModel.column_methods_hash.key?(:last_name) + assert_not TestModel.column_methods_hash.key?(:last_name) add_column :test_models, :last_name, :string @@ -41,7 +41,7 @@ module ActiveRecord remove_column :test_models, :last_name TestModel.reset_column_information - refute TestModel.column_methods_hash.key?(:last_name) + assert_not TestModel.column_methods_hash.key?(:last_name) end def test_unabstracted_database_dependent_types diff --git a/activerecord/test/cases/migration/index_test.rb b/activerecord/test/cases/migration/index_test.rb index 0787414d8f..a41f2c10f0 100644 --- a/activerecord/test/cases/migration/index_test.rb +++ b/activerecord/test/cases/migration/index_test.rb @@ -35,7 +35,7 @@ module ActiveRecord connection.rename_index(table_name, 'old_idx', 'new_idx') # if the adapter doesn't support the indexes call, pick defaults that let the test pass - refute connection.index_name_exists?(table_name, 'old_idx', false) + assert_not connection.index_name_exists?(table_name, 'old_idx', false) assert connection.index_name_exists?(table_name, 'new_idx', true) end @@ -63,7 +63,7 @@ module ActiveRecord connection.add_index(table_name, "foo", :name => too_long_index_name) } - refute connection.index_name_exists?(table_name, too_long_index_name, false) + assert_not connection.index_name_exists?(table_name, too_long_index_name, false) connection.add_index(table_name, "foo", :name => good_index_name) assert connection.index_name_exists?(table_name, good_index_name, false) @@ -75,7 +75,7 @@ module ActiveRecord assert connection.index_exists?(table_name, :foo, :name => :symbol_index_name) connection.remove_index table_name, :name => :symbol_index_name - refute connection.index_exists?(table_name, :foo, :name => :symbol_index_name) + assert_not connection.index_exists?(table_name, :foo, :name => :symbol_index_name) end def test_index_exists diff --git a/activerecord/test/cases/migration/references_index_test.rb b/activerecord/test/cases/migration/references_index_test.rb index 264a99f9ce..3ff89524fe 100644 --- a/activerecord/test/cases/migration/references_index_test.rb +++ b/activerecord/test/cases/migration/references_index_test.rb @@ -29,7 +29,7 @@ module ActiveRecord t.references :foo end - refute connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) + assert_not connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) end def test_does_not_create_index_explicit @@ -37,7 +37,7 @@ module ActiveRecord t.references :foo, :index => false end - refute connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) + assert_not connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) end def test_creates_index_with_options @@ -75,7 +75,7 @@ module ActiveRecord t.references :foo end - refute connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) + assert_not connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) end def test_does_not_create_index_for_existing_table_explicit @@ -84,7 +84,7 @@ module ActiveRecord t.references :foo, :index => false end - refute connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) + assert_not connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_foo_id) end def test_creates_polymorphic_index_for_existing_table diff --git a/activerecord/test/cases/migration/references_statements_test.rb b/activerecord/test/cases/migration/references_statements_test.rb index d8a6565d54..e9545f2cce 100644 --- a/activerecord/test/cases/migration/references_statements_test.rb +++ b/activerecord/test/cases/migration/references_statements_test.rb @@ -22,7 +22,7 @@ module ActiveRecord def test_does_not_create_reference_type_column add_reference table_name, :taggable - refute column_exists?(table_name, :taggable_type, :string) + assert_not column_exists?(table_name, :taggable_type, :string) end def test_creates_reference_type_column @@ -37,7 +37,7 @@ module ActiveRecord def test_does_not_create_reference_id_index add_reference table_name, :user - refute index_exists?(table_name, :user_id) + assert_not index_exists?(table_name, :user_id) end def test_creates_polymorphic_index @@ -57,19 +57,19 @@ module ActiveRecord def test_deletes_reference_id_column remove_reference table_name, :supplier - refute column_exists?(table_name, :supplier_id, :integer) + assert_not column_exists?(table_name, :supplier_id, :integer) end def test_deletes_reference_id_index remove_reference table_name, :supplier - refute index_exists?(table_name, :supplier_id) + assert_not index_exists?(table_name, :supplier_id) end def test_does_not_delete_reference_type_column with_polymorphic_column do remove_reference table_name, :supplier - refute column_exists?(table_name, :supplier_id, :integer) + assert_not column_exists?(table_name, :supplier_id, :integer) assert column_exists?(table_name, :supplier_type, :string) end end @@ -77,14 +77,14 @@ module ActiveRecord def test_deletes_reference_type_column with_polymorphic_column do remove_reference table_name, :supplier, polymorphic: true - refute column_exists?(table_name, :supplier_type, :string) + assert_not column_exists?(table_name, :supplier_type, :string) end end def test_deletes_polymorphic_index with_polymorphic_column do remove_reference table_name, :supplier, polymorphic: true - refute index_exists?(table_name, [:supplier_id, :supplier_type]) + assert_not index_exists?(table_name, [:supplier_id, :supplier_type]) end end @@ -95,7 +95,7 @@ module ActiveRecord def test_remove_belongs_to_alias remove_belongs_to table_name, :supplier - refute column_exists?(table_name, :supplier_id, :integer) + assert_not column_exists?(table_name, :supplier_id, :integer) end private diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index c155f29973..9cb64a6a71 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -232,7 +232,7 @@ class MigrationTest < ActiveRecord::TestCase skip "not supported on #{ActiveRecord::Base.connection.class}" end - refute Person.column_methods_hash.include?(:last_name) + assert_not Person.column_methods_hash.include?(:last_name) migration = Struct.new(:name, :version) { def migrate(x); raise 'Something broke'; end @@ -245,7 +245,7 @@ class MigrationTest < ActiveRecord::TestCase assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message Person.reset_column_information - refute Person.column_methods_hash.include?(:last_name) + assert_not Person.column_methods_hash.include?(:last_name) end def test_schema_migrations_table_name diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb index 199d0c584b..e905006570 100644 --- a/activerecord/test/cases/migrator_test.rb +++ b/activerecord/test/cases/migrator_test.rb @@ -121,11 +121,11 @@ module ActiveRecord ActiveRecord::Migrator.new(:up, pass_one).migrate assert pass_one.first.went_up - refute pass_one.first.went_down + assert_not pass_one.first.went_down pass_two = [Sensor.new('One', 1), Sensor.new('Three', 3)] ActiveRecord::Migrator.new(:up, pass_two).migrate - refute pass_two[0].went_up + assert_not pass_two[0].went_up assert pass_two[1].went_up assert pass_two.all? { |x| !x.went_down } @@ -135,7 +135,7 @@ module ActiveRecord ActiveRecord::Migrator.new(:down, pass_three).migrate assert pass_three[0].went_down - refute pass_three[1].went_down + assert_not pass_three[1].went_down assert pass_three[2].went_down end @@ -307,7 +307,7 @@ module ActiveRecord _, migrator = migrator_class(3) ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations") - refute ActiveRecord::Base.connection.table_exists?('schema_migrations') + assert_not ActiveRecord::Base.connection.table_exists?('schema_migrations') migrator.migrate("valid", 1) assert ActiveRecord::Base.connection.table_exists?('schema_migrations') end diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index fdca10f4fb..0c8b372e79 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -15,7 +15,7 @@ class TransactionTest < ActiveRecord::TestCase end def test_raise_after_destroy - refute @first.frozen? + assert_not @first.frozen? assert_raises(RuntimeError) { Topic.transaction do @@ -26,7 +26,7 @@ class TransactionTest < ActiveRecord::TestCase } assert @first.reload - refute @first.frozen? + assert_not @first.frozen? end def test_successful diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index e4f182a3aa..8b392c36d0 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -1,10 +1,11 @@ gem 'minitest' # make sure we get the gem, not stdlib -require 'minitest/spec' +require 'minitest/unit' require 'active_support/testing/tagged_logging' require 'active_support/testing/setup_and_teardown' require 'active_support/testing/assertions' require 'active_support/testing/deprecation' require 'active_support/testing/pending' +require 'active_support/testing/declarative' require 'active_support/testing/isolation' require 'active_support/testing/constant_lookup' require 'active_support/core_ext/kernel/reporting' @@ -16,13 +17,7 @@ rescue LoadError end module ActiveSupport - class TestCase < ::MiniTest::Spec - - # Use AS::TestCase for the base class when describing a model - register_spec_type(self) do |desc| - Class === desc && desc < ActiveRecord::Base - end - + class TestCase < ::MiniTest::Unit::TestCase Assertion = MiniTest::Assertion alias_method :method_name, :__name__ @@ -42,31 +37,22 @@ module ActiveSupport include ActiveSupport::Testing::Assertions include ActiveSupport::Testing::Deprecation include ActiveSupport::Testing::Pending - - def self.describe(text) - if block_given? - super - else - message = "`describe` without a block is deprecated, please switch to: `def self.name; #{text.inspect}; end`\n" - ActiveSupport::Deprecation.warn message - - class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def self.name - "#{text}" - end - RUBY_EVAL - end - end - - class << self - alias :test :it - end + extend ActiveSupport::Testing::Declarative # test/unit backwards compatibility methods alias :assert_raise :assert_raises - alias :assert_not_nil :refute_nil + alias :assert_not_empty :refute_empty alias :assert_not_equal :refute_equal + alias :assert_not_in_delta :refute_in_delta + alias :assert_not_in_epsilon :refute_in_epsilon + alias :assert_not_includes :refute_includes + alias :assert_not_instance_of :refute_instance_of + alias :assert_not_kind_of :refute_kind_of alias :assert_no_match :refute_match + alias :assert_not_nil :refute_nil + alias :assert_not_operator :refute_operator + alias :assert_not_predicate :refute_predicate + alias :assert_not_respond_to :refute_respond_to alias :assert_not_same :refute_same # Fails if the block raises an exception. diff --git a/activesupport/lib/active_support/testing/autorun.rb b/activesupport/lib/active_support/testing/autorun.rb new file mode 100644 index 0000000000..c446adc16d --- /dev/null +++ b/activesupport/lib/active_support/testing/autorun.rb @@ -0,0 +1,5 @@ +gem 'minitest' + +require 'minitest/unit' + +MiniTest::Unit.autorun diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb new file mode 100644 index 0000000000..508e37254a --- /dev/null +++ b/activesupport/lib/active_support/testing/declarative.rb @@ -0,0 +1,40 @@ +module ActiveSupport + module Testing + module Declarative + + def self.extended(klass) #:nodoc: + klass.class_eval do + + unless method_defined?(:describe) + def self.describe(text) + class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def self.name + "#{text}" + end + RUBY_EVAL + end + end + + end + end + + unless defined?(Spec) + # test "verify something" do + # ... + # end + def test(name, &block) + test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym + defined = instance_method(test_name) rescue false + raise "#{test_name} is already defined in #{self}" if defined + if block_given? + define_method(test_name, &block) + else + define_method(test_name) do + flunk "No implementation provided for #{name}" + end + end + end + end + end + end +end diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 8a67b148c3..90e50f235b 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -15,7 +15,7 @@ silence_warnings do Encoding.default_external = "UTF-8" end -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'empty_bool' ENV['NO_RELOAD'] = '1' diff --git a/activesupport/test/core_ext/thread_test.rb b/activesupport/test/core_ext/thread_test.rb index b58f59a8d4..230c1203ad 100644 --- a/activesupport/test/core_ext/thread_test.rb +++ b/activesupport/test/core_ext/thread_test.rb @@ -39,14 +39,14 @@ class ThreadExt < ActiveSupport::TestCase end def test_thread_variable? - refute Thread.new { Thread.current.thread_variable?("foo") }.join.value + assert_not Thread.new { Thread.current.thread_variable?("foo") }.join.value t = Thread.new { Thread.current.thread_variable_set("foo", "bar") }.join assert t.thread_variable?("foo") assert t.thread_variable?(:foo) - refute t.thread_variable?(:bar) + assert_not t.thread_variable?(:bar) end def test_thread_variable_strings_and_symbols_are_the_same_key diff --git a/activesupport/test/spec_type_test.rb b/activesupport/test/spec_type_test.rb deleted file mode 100644 index 9a6cb4ded2..0000000000 --- a/activesupport/test/spec_type_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "abstract_unit" -require "active_record" - -class SomeRandomModel < ActiveRecord::Base; end - -class SpecTypeTest < ActiveSupport::TestCase - def assert_support actual - assert_equal ActiveSupport::TestCase, actual - end - - def assert_spec actual - assert_equal MiniTest::Spec, actual - end - - def test_spec_type_resolves_for_active_record_constants - assert_support MiniTest::Spec.spec_type(SomeRandomModel) - end - - def test_spec_type_doesnt_resolve_random_strings - assert_spec MiniTest::Spec.spec_type("Unmatched String") - end -end diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb index 94d5fe197d..a2ed577eb0 100644 --- a/activesupport/test/string_inquirer_test.rb +++ b/activesupport/test/string_inquirer_test.rb @@ -10,7 +10,7 @@ class StringInquirerTest < ActiveSupport::TestCase end def test_miss - refute @string_inquirer.development? + assert_not @string_inquirer.development? end def test_missing_question_mark diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb index 2c217157d3..294d6595f7 100644 --- a/activesupport/test/ts_isolated.rb +++ b/activesupport/test/ts_isolated.rb @@ -1,4 +1,4 @@ -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'active_support/test_case' require 'rbconfig' require 'active_support/core_ext/kernel/reporting' diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index ce2a5a4902..7c5a472971 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -214,7 +214,8 @@ Rails follows a simple set of coding style conventions: * Prefer `&&`/`||` over `and`/`or`. * Prefer class << self over self.method for class methods. * Use `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`. -* Use a = b and not a=b. +* Use `a = b` and not `a=b`. +* Use assert_not methods instead of refute. * Follow the conventions in the source you see used already. The above are guidelines — please use your best judgment in using them. @@ -403,7 +404,7 @@ following: ```bash $ git fetch upstream -$ git checkout my_pull_request +$ git checkout my_pull_request $ git rebase upstream/master $ git rebase -i diff --git a/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb b/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb index c9af2ca832..30a861f09d 100644 --- a/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +++ b/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb @@ -1,2 +1,2 @@ -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'active_support' diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index aed7fd4b14..616206dd0b 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -2,7 +2,7 @@ # so fixtures aren't loaded into that environment abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production? -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'active_support/test_case' require 'action_controller/test_case' require 'action_dispatch/testing/integration' diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index ecd5e03978..491faf4af9 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -3,7 +3,7 @@ ENV["RAILS_ENV"] ||= "test" require File.expand_path("../../../load_paths", __FILE__) require 'stringio' -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'fileutils' require 'active_support' diff --git a/railties/test/configuration/middleware_stack_proxy_test.rb b/railties/test/configuration/middleware_stack_proxy_test.rb index 5984c0b425..2442cb995d 100644 --- a/railties/test/configuration/middleware_stack_proxy_test.rb +++ b/railties/test/configuration/middleware_stack_proxy_test.rb @@ -1,6 +1,7 @@ -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'rails/configuration' require 'active_support/test_case' +require 'minitest/mock' module Rails module Configuration diff --git a/railties/test/engine_test.rb b/railties/test/engine_test.rb index addf49cdb6..7970913d21 100644 --- a/railties/test/engine_test.rb +++ b/railties/test/engine_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' class EngineTest < ActiveSupport::TestCase - it "reports routes as available only if they're actually present" do + test "reports routes as available only if they're actually present" do engine = Class.new(Rails::Engine) do def initialize(*args) @routes = nil diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 0cb65f8e0d..172a42a549 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -9,7 +9,7 @@ require 'fileutils' require 'bundler/setup' unless defined?(Bundler) -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'active_support/test_case' RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..") |