diff --git a/test/generators/test_controller_generator.rb b/test/generators/test_controller_generator.rb index 06c04582..d93a2f3e 100644 --- a/test/generators/test_controller_generator.rb +++ b/test/generators/test_controller_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/controller/controller_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/generators/test_helper_generator.rb b/test/generators/test_helper_generator.rb index 189e6aab..97086287 100644 --- a/test/generators/test_helper_generator.rb +++ b/test/generators/test_helper_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/helper/helper_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/generators/test_install_generator.rb b/test/generators/test_install_generator.rb index c6ec47bd..224aca34 100644 --- a/test/generators/test_install_generator.rb +++ b/test/generators/test_install_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/install/install_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/generators/test_mailer_generator.rb b/test/generators/test_mailer_generator.rb index 6a2cb4e7..cf69d7fe 100644 --- a/test/generators/test_mailer_generator.rb +++ b/test/generators/test_mailer_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/mailer/mailer_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/generators/test_model_generator.rb b/test/generators/test_model_generator.rb index 223be658..360e6c15 100644 --- a/test/generators/test_model_generator.rb +++ b/test/generators/test_model_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/model/model_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/generators/test_scaffold_generator.rb b/test/generators/test_scaffold_generator.rb index 619109e5..5b5dd5d8 100644 --- a/test/generators/test_scaffold_generator.rb +++ b/test/generators/test_scaffold_generator.rb @@ -1,13 +1,6 @@ -require "minitest/autorun" -require "minitest-rails" - -require "rails" -require "rails/generators" - +require "helper" require "generators/mini_test/scaffold/scaffold_generator" -require "fakefs/safe" - class FakeFS::File def self.binread file File.open(file, "rb") { |f| f.read } diff --git a/test/helper.rb b/test/helper.rb new file mode 100644 index 00000000..5223712a --- /dev/null +++ b/test/helper.rb @@ -0,0 +1,16 @@ +require "minitest/autorun" + +require "rails" +require "rails/generators" + +require "active_record" + +require "action_controller" +require "action_controller/railtie" + +require "action_mailer" + +require "minitest-rails" +require "minitest/rails" + +require "fakefs/safe" \ No newline at end of file diff --git a/test/rails/action_controller/test_controllers.rb b/test/rails/action_controller/test_controllers.rb index df99c313..1cbce0c3 100644 --- a/test/rails/action_controller/test_controllers.rb +++ b/test/rails/action_controller/test_controllers.rb @@ -1,10 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "action_controller" -require "action_controller/railtie" - -require "minitest/rails" +require "helper" class TestApp < Rails::Application end diff --git a/test/rails/action_controller/test_spec_type.rb b/test/rails/action_controller/test_spec_type.rb index 8ef3f93c..6a84327e 100644 --- a/test/rails/action_controller/test_spec_type.rb +++ b/test/rails/action_controller/test_spec_type.rb @@ -1,9 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "action_controller" - -require "minitest/rails" +require "helper" class ApplicationController < ActionController::Base; end class ModelsController < ApplicationController; end diff --git a/test/rails/action_dispatch/test_spec_type.rb b/test/rails/action_dispatch/test_spec_type.rb index e110fcf2..2380a5e8 100644 --- a/test/rails/action_dispatch/test_spec_type.rb +++ b/test/rails/action_dispatch/test_spec_type.rb @@ -1,7 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "minitest/rails" +require "helper" class TestActionDispatchSpecType < MiniTest::Unit::TestCase def assert_dispatch actual diff --git a/test/rails/action_mailer/test_mailers.rb b/test/rails/action_mailer/test_mailers.rb index 100fde86..aaa10cdd 100644 --- a/test/rails/action_mailer/test_mailers.rb +++ b/test/rails/action_mailer/test_mailers.rb @@ -1,114 +1,109 @@ -require "minitest/autorun" -require "rails" - -require "action_mailer" - -require "minitest/rails" +require "helper" class TestTestMailer < ActionMailer::Base; end # From Rails... -# class CrazyNameMailerTest < ActionMailer::TestCase -# tests TestTestMailer - -# def test_set_mailer_class_manual -# assert_equal TestTestMailer, self.class.mailer_class -# end -# end - -# class CrazySymbolNameMailerTest < ActionMailer::TestCase -# tests :test_test_mailer - -# def test_set_mailer_class_manual_using_symbol -# assert_equal TestTestMailer, self.class.mailer_class -# end -# end if Rails::VERSION::STRING >= "3.2" - -# class CrazyStringNameMailerTest < ActionMailer::TestCase -# tests 'test_test_mailer' - -# def test_set_mailer_class_manual_using_string -# assert_equal TestTestMailer, self.class.mailer_class -# end -# end if Rails::VERSION::STRING >= "3.2" - -# # New tests... -# 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 "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 if Rails::VERSION::STRING >= "3.2" - -# 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 if Rails::VERSION::STRING >= "3.2" - -# 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 if Rails::VERSION::STRING >= "3.2" - -# 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 if Rails::VERSION::STRING >= "3.2" +class CrazyNameMailerTest < ActionMailer::TestCase + tests TestTestMailer + + def test_set_mailer_class_manual + assert_equal TestTestMailer, self.class.mailer_class + end +end + +class CrazySymbolNameMailerTest < ActionMailer::TestCase + tests :test_test_mailer + + def test_set_mailer_class_manual_using_symbol + assert_equal TestTestMailer, self.class.mailer_class + end +end if Rails::VERSION::STRING >= "3.2" + +class CrazyStringNameMailerTest < ActionMailer::TestCase + tests 'test_test_mailer' + + def test_set_mailer_class_manual_using_string + assert_equal TestTestMailer, self.class.mailer_class + end +end if Rails::VERSION::STRING >= "3.2" + +# New tests... +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 "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 if Rails::VERSION::STRING >= "3.2" + +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 if Rails::VERSION::STRING >= "3.2" + +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 if Rails::VERSION::STRING >= "3.2" + +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 if Rails::VERSION::STRING >= "3.2" diff --git a/test/rails/action_mailer/test_spec_type.rb b/test/rails/action_mailer/test_spec_type.rb index 4d5f99c9..c026751b 100644 --- a/test/rails/action_mailer/test_spec_type.rb +++ b/test/rails/action_mailer/test_spec_type.rb @@ -1,10 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "action_mailer" -require "action_mailer/test_helper" - -load "minitest/rails.rb" # force load to ensure ActionMailer is defined +require "helper" class NotificationMailer < ActionMailer::Base; end class Notifications < ActionMailer::Base; end diff --git a/test/rails/action_view/test_helpers.rb b/test/rails/action_view/test_helpers.rb index fd3e644a..18e1145e 100644 --- a/test/rails/action_view/test_helpers.rb +++ b/test/rails/action_view/test_helpers.rb @@ -1,7 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "minitest/rails" +require "helper" module PeopleHelper def title(text) diff --git a/test/rails/action_view/test_spec_type.rb b/test/rails/action_view/test_spec_type.rb index 34d6f111..21ba1253 100644 --- a/test/rails/action_view/test_spec_type.rb +++ b/test/rails/action_view/test_spec_type.rb @@ -1,7 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "minitest/rails" +require "helper" class TestActionViewSpecType < MiniTest::Unit::TestCase def assert_view actual diff --git a/test/rails/active_support/test_spec_type.rb b/test/rails/active_support/test_spec_type.rb index bb2626ab..6b2b64f0 100644 --- a/test/rails/active_support/test_spec_type.rb +++ b/test/rails/active_support/test_spec_type.rb @@ -1,10 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "active_record" - -require "minitest/rails" -load "minitest/rails/test_case.rb" # force load to ensure ActiveRecord is defined +require "helper" class SomeRandomModel < ActiveRecord::Base; end diff --git a/test/rails/test_constant_lookup.rb b/test/rails/test_constant_lookup.rb index 3277e61d..5c6eb934 100644 --- a/test/rails/test_constant_lookup.rb +++ b/test/rails/test_constant_lookup.rb @@ -1,7 +1,4 @@ -require "minitest/autorun" -require "rails" - -require "minitest/rails" +require "helper" class Foo; end class Bar < Foo; diff --git a/test/test_sanity.rb b/test/test_sanity.rb index bd2b0123..c8f9d5f2 100644 --- a/test/test_sanity.rb +++ b/test/test_sanity.rb @@ -1,5 +1,4 @@ -require "minitest/autorun" -require "minitest-rails" +require "helper" class TestMiniTest < MiniTest::Unit::TestCase def test_sanity