Add the new generators environment and update commands.
This commit is contained in:
parent
c9ea21717e
commit
09c288f0c5
|
@ -1,5 +1,5 @@
|
|||
RAILS_ENV.replace "generators"
|
||||
require "#{RAILS_ROOT}/config/environment"
|
||||
require 'generators'
|
||||
|
||||
if ARGV.size == 0
|
||||
Rails::Generators.help
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
RAILS_ENV.replace "generators"
|
||||
require "#{RAILS_ROOT}/config/environment"
|
||||
require 'generators'
|
||||
|
||||
if ARGV.size == 0
|
||||
Rails::Generators.help
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
RAILS_ENV.replace "generators"
|
||||
require "#{RAILS_ROOT}/config/environment"
|
||||
require 'generators'
|
||||
|
||||
if ARGV.size == 0
|
||||
Rails::Generators.help
|
||||
|
|
|
@ -38,13 +38,13 @@ module Rails
|
|||
:helper => true,
|
||||
:layout => true,
|
||||
:migration => true,
|
||||
:orm => 'active_record',
|
||||
:resource_controller => 'controller',
|
||||
:scaffold_controller => 'scaffold_controller',
|
||||
:orm => :active_record,
|
||||
:resource_controller => :controller,
|
||||
:scaffold_controller => :scaffold_controller,
|
||||
:singleton => false,
|
||||
:stylesheets => true,
|
||||
:test_framework => 'test_unit',
|
||||
:template_engine => 'erb',
|
||||
:test_framework => :test_unit,
|
||||
:template_engine => :erb,
|
||||
:timestamps => true
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ module Rails
|
|||
end
|
||||
shell.padding -= 1
|
||||
else
|
||||
say "Could not find and invoke '\#{klass_name}'."
|
||||
say_status :error, "\#{klass_name} [not found]", :red
|
||||
end
|
||||
end
|
||||
METHOD
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'digest/md5'
|
||||
require 'active_support/secure_random'
|
||||
require 'rails/version' unless defined?(RAILS::VERSION)
|
||||
require 'rails/version' unless defined?(Rails::VERSION)
|
||||
|
||||
module Rails::Generators
|
||||
class AppGenerator < Base
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# Cache classes and log when you accidentally call methods on nil.
|
||||
config.cache_classes = false
|
||||
config.whiny_nils = true
|
||||
|
||||
# We do not need any framework on generators. They are loaded on demand.
|
||||
config.frameworks.clear
|
||||
|
||||
# Configure generators. Below you have the default values, delete them if you want.
|
||||
config.generators do |g|
|
||||
g.helper = true
|
||||
g.layout = true
|
||||
g.orm = :active_record
|
||||
g.stylesheets = true
|
||||
g.template_engine = :erb
|
||||
g.test_framework = :test_unit
|
||||
g.timestamps = true
|
||||
end
|
|
@ -572,7 +572,7 @@ Run `rake gems:install` to install the missing gems.
|
|||
# Load generators if RAILS_ENV == "generators"
|
||||
Initializer.default.add :initialize_generators do
|
||||
if RAILS_ENV == "generators"
|
||||
require 'generators'
|
||||
require "generators"
|
||||
Rails::Generators.no_color! unless config.generators.colorize_logging
|
||||
Rails::Generators.aliases.merge! config.generators.aliases
|
||||
Rails::Generators.options.merge! config.generators.options
|
||||
|
|
|
@ -18,8 +18,8 @@ class HelperGeneratorTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_logs_if_the_test_framework_cannot_be_found
|
||||
content = run_generator ["admin", "--test-framework=unknown"]
|
||||
assert_match /Could not find and invoke 'unknown'/, content
|
||||
content = run_generator ["admin", "--test-framework=rspec"]
|
||||
assert_match /rspec \[not found\]/, content
|
||||
end
|
||||
|
||||
def test_check_class_collision
|
||||
|
|
|
@ -33,8 +33,8 @@ class MailerGeneratorTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_logs_if_the_template_engine_cannot_be_found
|
||||
content = run_generator ["notifier", "foo", "bar", "--template-engine=unknown"]
|
||||
assert_match /Could not find and invoke 'unknown'/, content
|
||||
content = run_generator ["notifier", "foo", "bar", "--template-engine=haml"]
|
||||
assert_match /haml \[not found\]/, content
|
||||
end
|
||||
|
||||
def test_actions_are_turned_into_methods
|
||||
|
|
|
@ -108,7 +108,7 @@ class ModelGeneratorTest < GeneratorsTestCase
|
|||
|
||||
def test_fixture_is_skipped_if_fixture_replacement_is_given
|
||||
content = run_generator ["account", "-r", "factory_girl"]
|
||||
assert_match /Could not find and invoke 'factory_girl'/, content
|
||||
assert_match /factory_girl \[not found\]/, content
|
||||
assert_no_file "test/fixtures/accounts.yml"
|
||||
end
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ class ObserverGeneratorTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_logs_if_the_test_framework_cannot_be_found
|
||||
content = run_generator ["account", "--test-framework=unknown"]
|
||||
assert_match /Could not find and invoke 'unknown'/, content
|
||||
content = run_generator ["account", "--test-framework=rspec"]
|
||||
assert_match /rspec \[not found\]/, content
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -26,8 +26,8 @@ class PluginGeneratorTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_logs_if_the_test_framework_cannot_be_found
|
||||
content = run_generator ["plugin_fu", "--test-framework=unknown"]
|
||||
assert_match /Could not find and invoke 'unknown'/, content
|
||||
content = run_generator ["plugin_fu", "--test-framework=rspec"]
|
||||
assert_match /rspec \[not found\]/, content
|
||||
end
|
||||
|
||||
def test_creates_tasks_if_required
|
||||
|
|
|
@ -352,7 +352,7 @@ class InitializerGeneratorsTests < Test::Unit::TestCase
|
|||
def test_generators_are_not_invoked_with_other_environments
|
||||
@configuration.generators.test_framework = :rspec
|
||||
@initializer.run(:initialize_generators)
|
||||
assert_equal "test_unit", Rails::Generators.options[:test_framework]
|
||||
assert_equal :test_unit, Rails::Generators.options[:test_framework]
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Reference in New Issue