Permalink
Browse files

Add test helper

Since the changes for Rails 4 the TestCase duck-punches aren't as isolated.
Add this helper file so that everything gets loaded once.
No more calling 'load' instead of 'require'.
Uncomment the mailer tests. It was a mistake to comment them out.
  • Loading branch information...
1 parent bfa5313 commit 36f7115f34f221afd47c4a8d05d28d2878953017 @blowmage committed Jan 10, 2013
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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 }
View
@@ -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"
@@ -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
@@ -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
@@ -1,7 +1,4 @@
-require "minitest/autorun"
-require "rails"
-
-require "minitest/rails"
+require "helper"
class TestActionDispatchSpecType < MiniTest::Unit::TestCase
def assert_dispatch actual
@@ -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"
@@ -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
@@ -1,7 +1,4 @@
-require "minitest/autorun"
-require "rails"
-
-require "minitest/rails"
+require "helper"
module PeopleHelper
def title(text)
@@ -1,7 +1,4 @@
-require "minitest/autorun"
-require "rails"
-
-require "minitest/rails"
+require "helper"
class TestActionViewSpecType < MiniTest::Unit::TestCase
def assert_view actual
Oops, something went wrong.

0 comments on commit 36f7115

Please sign in to comment.