aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/actions_test.rb18
-rw-r--r--railties/test/generators/app_generator_test.rb16
-rw-r--r--railties/test/generators/controller_generator_test.rb5
-rw-r--r--railties/test/generators/generator_generator_test.rb5
-rw-r--r--railties/test/generators/generators_test_helper.rb22
-rw-r--r--railties/test/generators/helper_generator_test.rb5
-rw-r--r--railties/test/generators/integration_test_generator_test.rb5
-rw-r--r--railties/test/generators/mailer_generator_test.rb13
-rw-r--r--railties/test/generators/metal_generator_test.rb5
-rw-r--r--railties/test/generators/migration_generator_test.rb6
-rw-r--r--railties/test/generators/model_generator_test.rb5
-rw-r--r--railties/test/generators/named_base_test.rb5
-rw-r--r--railties/test/generators/observer_generator_test.rb5
-rw-r--r--railties/test/generators/performance_test_generator_test.rb5
-rw-r--r--railties/test/generators/plugin_generator_test.rb20
-rw-r--r--railties/test/generators/resource_generator_test.rb5
-rw-r--r--railties/test/generators/scaffold_controller_generator_test.rb5
-rw-r--r--railties/test/generators/scaffold_generator_test.rb5
-rw-r--r--railties/test/generators/session_migration_generator_test.rb6
-rw-r--r--railties/test/generators/stylesheets_generator_test.rb6
20 files changed, 107 insertions, 60 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 27b6a49566..cb1fa96e0d 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -1,7 +1,11 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/app/app_generator'
+require 'generators/rails/app/app_generator'
-class ActionsTest < GeneratorsTestCase
+# TODO This line shouldn't be required
+require 'generators/rails/model/model_generator'
+
+class ActionsTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
tests Rails::Generators::AppGenerator
arguments [destination_root]
@@ -11,6 +15,16 @@ class ActionsTest < GeneratorsTestCase
@svn_plugin_uri = 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
end
+ def test_invoke_other_generator_with_shortcut
+ action :invoke, 'model', ['my_model']
+ assert_file 'app/models/my_model.rb', /MyModel/
+ end
+
+ def test_invoke_other_generator_with_full_namespace
+ action :invoke, 'rails:model', ['my_model']
+ assert_file 'app/models/my_model.rb', /MyModel/
+ end
+
def test_create_file_should_write_data_to_file_path
action :create_file, 'lib/test_file.rb', 'heres test data'
assert_file 'lib/test_file.rb', 'heres test data'
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 62ea07f14e..f821f5caf3 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -1,8 +1,9 @@
require 'abstract_unit'
require 'generators/generators_test_helper'
-require 'rails/generators/rails/app/app_generator'
+require 'generators/rails/app/app_generator'
-class AppGeneratorTest < GeneratorsTestCase
+class AppGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments [destination_root]
def setup
@@ -80,11 +81,10 @@ class AppGeneratorTest < GeneratorsTestCase
assert_no_file "config/database.yml"
end
- # TODO: Bring this back using requires
- # def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
- # run_generator ["--skip-activerecord"]
- # assert_file "config/application.rb", /config\.frameworks \-= \[ :active_record \]/
- # end
+ def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
+ run_generator [destination_root, "--skip-activerecord"]
+ assert_file "config/boot.rb", /# require "active_record\/railtie"/
+ end
def test_prototype_and_test_unit_are_added_by_default
run_generator
@@ -159,7 +159,7 @@ class AppGeneratorTest < GeneratorsTestCase
end
def test_default_namespace
- assert_match "rails:generators:app", Rails::Generators::AppGenerator.namespace
+ assert_match "rails:app", Rails::Generators::AppGenerator.namespace
end
def test_file_is_added_for_backwards_compatibility
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb
index 8e2fd3b9ed..79a4e5bf17 100644
--- a/railties/test/generators/controller_generator_test.rb
+++ b/railties/test/generators/controller_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/controller/controller_generator'
+require 'generators/rails/controller/controller_generator'
-class ControllerGeneratorTest < GeneratorsTestCase
+class ControllerGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(Account foo bar)
def test_help_does_not_show_invoked_generators_options_if_they_already_exist
diff --git a/railties/test/generators/generator_generator_test.rb b/railties/test/generators/generator_generator_test.rb
index 28377f23b0..f3fd688e4f 100644
--- a/railties/test/generators/generator_generator_test.rb
+++ b/railties/test/generators/generator_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/generator/generator_generator'
+require 'generators/rails/generator/generator_generator'
-class GeneratorGeneratorTest < GeneratorsTestCase
+class GeneratorGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(awesome)
def test_generator_skeleton_is_created
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index 54953b76c8..3cd16a69f9 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -10,21 +10,19 @@ Rails.application.config.root = Rails.root
require 'rails/generators'
require 'rails/generators/test_case'
-require 'rubygems'
require 'active_record'
require 'action_dispatch'
-class GeneratorsTestCase < Rails::Generators::TestCase
- destination File.join(Rails.root, "tmp")
- setup :prepare_destination
+module GeneratorsTestHelper
+ def self.included(base)
+ base.class_eval do
+ destination File.join(Rails.root, "tmp")
+ setup :prepare_destination
- def self.inherited(base)
- base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
- rescue
- # Do nothing.
- end
-
- def test_truth
- # Don't cry test/unit
+ begin
+ base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
+ rescue
+ end
+ end
end
end \ No newline at end of file
diff --git a/railties/test/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb
index cf18782986..6d7168738e 100644
--- a/railties/test/generators/helper_generator_test.rb
+++ b/railties/test/generators/helper_generator_test.rb
@@ -1,10 +1,11 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/helper/helper_generator'
+require 'generators/rails/helper/helper_generator'
ObjectHelper = Class.new
AnotherObjectHelperTest = Class.new
-class HelperGeneratorTest < GeneratorsTestCase
+class HelperGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(admin)
def test_helper_skeleton_is_created
diff --git a/railties/test/generators/integration_test_generator_test.rb b/railties/test/generators/integration_test_generator_test.rb
index 88e18be5b2..d7fc324c88 100644
--- a/railties/test/generators/integration_test_generator_test.rb
+++ b/railties/test/generators/integration_test_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/integration_test/integration_test_generator'
+require 'generators/rails/integration_test/integration_test_generator'
-class IntegrationTestGeneratorTest < GeneratorsTestCase
+class IntegrationTestGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(integration)
def test_integration_test_skeleton_is_created
diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb
index ee4346eb71..dfc3130f77 100644
--- a/railties/test/generators/mailer_generator_test.rb
+++ b/railties/test/generators/mailer_generator_test.rb
@@ -1,12 +1,13 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/mailer/mailer_generator'
+require 'generators/rails/mailer/mailer_generator'
-class MailerGeneratorTest < GeneratorsTestCase
+class MailerGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(notifier foo bar)
def test_mailer_skeleton_is_created
run_generator
- assert_file "app/models/notifier.rb", /class Notifier < ActionMailer::Base/
+ assert_file "app/mailers/notifier.rb", /class Notifier < ActionMailer::Base/
end
def test_check_class_collision
@@ -16,7 +17,7 @@ class MailerGeneratorTest < GeneratorsTestCase
def test_invokes_default_test_framework
run_generator
- assert_file "test/unit/notifier_test.rb", /class NotifierTest < ActionMailer::TestCase/
+ assert_file "test/functional/notifier_test.rb", /class NotifierTest < ActionMailer::TestCase/
assert_file "test/fixtures/notifier/foo", /app\/views\/notifier\/foo/
assert_file "test/fixtures/notifier/bar", /app\/views\/notifier\/bar/
end
@@ -39,7 +40,7 @@ class MailerGeneratorTest < GeneratorsTestCase
def test_actions_are_turned_into_methods
run_generator
- assert_file "app/models/notifier.rb", /def foo/
- assert_file "app/models/notifier.rb", /def bar/
+ assert_file "app/mailers/notifier.rb", /def foo/
+ assert_file "app/mailers/notifier.rb", /def bar/
end
end
diff --git a/railties/test/generators/metal_generator_test.rb b/railties/test/generators/metal_generator_test.rb
index 5d6a277561..e3a2384885 100644
--- a/railties/test/generators/metal_generator_test.rb
+++ b/railties/test/generators/metal_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/metal/metal_generator'
+require 'generators/rails/metal/metal_generator'
-class MetalGeneratorTest < GeneratorsTestCase
+class MetalGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(foo)
def test_metal_skeleton_is_created
diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb
index 2fd3e5c056..811a712fd5 100644
--- a/railties/test/generators/migration_generator_test.rb
+++ b/railties/test/generators/migration_generator_test.rb
@@ -1,7 +1,9 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/migration/migration_generator'
+require 'generators/rails/migration/migration_generator'
+
+class MigrationGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
-class MigrationGeneratorTest < GeneratorsTestCase
def test_migration
migration = "change_title_body_from_posts"
run_generator [migration]
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb
index 051a43706b..79ce9a2a7b 100644
--- a/railties/test/generators/model_generator_test.rb
+++ b/railties/test/generators/model_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/model/model_generator'
+require 'generators/rails/model/model_generator'
-class ModelGeneratorTest < GeneratorsTestCase
+class ModelGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(Account name:string age:integer)
def test_help_shows_invoked_generators_options
diff --git a/railties/test/generators/named_base_test.rb b/railties/test/generators/named_base_test.rb
index 8c1df3b992..99eb431a49 100644
--- a/railties/test/generators/named_base_test.rb
+++ b/railties/test/generators/named_base_test.rb
@@ -1,5 +1,5 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
+require 'generators/rails/scaffold_controller/scaffold_controller_generator'
# Mock out what we need from AR::Base.
module ActiveRecord
@@ -11,7 +11,8 @@ module ActiveRecord
end
end
-class NamedBaseTest < GeneratorsTestCase
+class NamedBaseTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
tests Rails::Generators::ScaffoldControllerGenerator
def test_named_generator_attributes
diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb
index 44d9e4a9f3..058a19228d 100644
--- a/railties/test/generators/observer_generator_test.rb
+++ b/railties/test/generators/observer_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/observer/observer_generator'
+require 'generators/rails/observer/observer_generator'
-class ObserverGeneratorTest < GeneratorsTestCase
+class ObserverGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(account)
def test_invokes_default_orm
diff --git a/railties/test/generators/performance_test_generator_test.rb b/railties/test/generators/performance_test_generator_test.rb
index 099575ea1d..c95063a127 100644
--- a/railties/test/generators/performance_test_generator_test.rb
+++ b/railties/test/generators/performance_test_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/performance_test/performance_test_generator'
+require 'generators/rails/performance_test/performance_test_generator'
-class PerformanceTestGeneratorTest < GeneratorsTestCase
+class PerformanceTestGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(performance)
def test_performance_test_skeleton_is_created
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index f84b8b6d50..4bfe210efb 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -1,17 +1,33 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/plugin/plugin_generator'
+require 'generators/rails/plugin/plugin_generator'
-class PluginGeneratorTest < GeneratorsTestCase
+class PluginGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(plugin_fu)
def test_plugin_skeleton_is_created
run_generator
+ year = Date.today.year
%w(
vendor/plugins
vendor/plugins/plugin_fu
+ vendor/plugins/plugin_fu/init.rb
+ vendor/plugins/plugin_fu/install.rb
+ vendor/plugins/plugin_fu/uninstall.rb
vendor/plugins/plugin_fu/lib
+ vendor/plugins/plugin_fu/lib/plugin_fu.rb
).each{ |path| assert_file path }
+
+ %w(
+ vendor/plugins/plugin_fu/README
+ vendor/plugins/plugin_fu/Rakefile
+ ).each{ |path| assert_file path, /PluginFu/ }
+
+ %w(
+ vendor/plugins/plugin_fu/README
+ vendor/plugins/plugin_fu/MIT-LICENSE
+ ).each{ |path| assert_file path, /#{year}/ }
end
def test_check_class_collision
diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb
index 15c0ca0f01..959934bd71 100644
--- a/railties/test/generators/resource_generator_test.rb
+++ b/railties/test/generators/resource_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/resource/resource_generator'
+require 'generators/rails/resource/resource_generator'
-class ResourceGeneratorTest < GeneratorsTestCase
+class ResourceGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(account)
def setup
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb
index 7593c14dd9..f971598d18 100644
--- a/railties/test/generators/scaffold_controller_generator_test.rb
+++ b/railties/test/generators/scaffold_controller_generator_test.rb
@@ -1,12 +1,13 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
+require 'generators/rails/scaffold_controller/scaffold_controller_generator'
module Unknown
module Generators
end
end
-class ScaffoldControllerGeneratorTest < GeneratorsTestCase
+class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(User name:string age:integer)
def test_controller_skeleton_is_created
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb
index 4ddc7b1c89..a7e9c8a231 100644
--- a/railties/test/generators/scaffold_generator_test.rb
+++ b/railties/test/generators/scaffold_generator_test.rb
@@ -1,7 +1,8 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/scaffold/scaffold_generator'
+require 'generators/rails/scaffold/scaffold_generator'
-class ScaffoldGeneratorTest < GeneratorsTestCase
+class ScaffoldGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
arguments %w(product_line title:string price:integer)
def setup
diff --git a/railties/test/generators/session_migration_generator_test.rb b/railties/test/generators/session_migration_generator_test.rb
index 251ffb19ed..de28b4c75b 100644
--- a/railties/test/generators/session_migration_generator_test.rb
+++ b/railties/test/generators/session_migration_generator_test.rb
@@ -1,7 +1,9 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/session_migration/session_migration_generator'
+require 'generators/rails/session_migration/session_migration_generator'
+
+class SessionMigrationGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
-class SessionMigrationGeneratorTest < GeneratorsTestCase
def test_session_migration_with_default_name
run_generator
assert_migration "db/migrate/add_sessions_table.rb", /class AddSessionsTable < ActiveRecord::Migration/
diff --git a/railties/test/generators/stylesheets_generator_test.rb b/railties/test/generators/stylesheets_generator_test.rb
index d9079327ba..718fcb1fa7 100644
--- a/railties/test/generators/stylesheets_generator_test.rb
+++ b/railties/test/generators/stylesheets_generator_test.rb
@@ -1,7 +1,9 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/stylesheets/stylesheets_generator'
+require 'generators/rails/stylesheets/stylesheets_generator'
+
+class StylesheetsGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
-class StylesheetsGeneratorTest < GeneratorsTestCase
def test_copy_stylesheets
run_generator
assert_file "public/stylesheets/scaffold.css"