Permalink
Browse files

Pass more options to test/dummy in 'plugin new' generator

  • Loading branch information...
1 parent 671d146 commit 46fdb3197d270551da260cfed3dea7928dd15b0f @drogus committed Oct 26, 2010
@@ -8,6 +8,9 @@
module Rails
module Generators
class AppBase < Base
+ DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
+ JAVASCRIPTS = %w( prototype jquery )
+
attr_accessor :rails_template
add_shebang_option!
@@ -26,10 +29,17 @@ def self.add_shared_options_for(name)
class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
:desc => "Skip Git ignores and keeps"
- skip_active_record_desc = "Skip Active Record files"
- skip_active_record_desc << " for dummy application" if name == "plugin"
class_option :skip_active_record, :type => :boolean, :aliases => "-O", :default => false,
- :desc => skip_active_record_desc
+ :desc => "Skip Active Record files"
+
+ class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3",
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
+
+ class_option :javascript, :type => :string, :aliases => "-j", :default => "prototype",
+ :desc => "Preconfigure for selected javascript library (options: #{JAVASCRIPTS.join('/')})"
+
+ class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false,
+ :desc => "Skip javascript files"
class_option :dev, :type => :boolean, :default => false,
:desc => "Setup the #{name} with Gemfile pointing to your Rails checkout"
@@ -154,23 +154,11 @@ module Generators
plugin runner test]
class AppGenerator < AppBase
- DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
- JAVASCRIPTS = %w( prototype jquery )
-
add_shared_options_for "application"
- class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3",
- :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
-
- class_option :javascript, :type => :string, :aliases => "-j", :default => "prototype",
- :desc => "Preconfigure for selected javascript library (options: #{JAVASCRIPTS.join('/')})"
-
class_option :skip_test_unit, :type => :boolean, :aliases => "-T", :default => false,
:desc => "Skip Test::Unit files"
- class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false,
- :desc => "Skip javascript files"
-
# Add bin/rails options
class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
:desc => "Show Rails version number and quit"
@@ -45,7 +45,7 @@ def test
end
def generate_test_dummy
- opts = (options || {}).slice("skip_active_record")
+ opts = (options || {}).slice(:skip_active_record, :skip_javascript, :database, :javascript)
invoke Rails::Generators::AppGenerator,
[ File.expand_path(dummy_path, destination_root) ], opts
@@ -63,6 +63,21 @@ def test_ensure_that_skip_active_record_option_is_passed_to_app_generator
assert_no_file "test/dummy/config/database.yml"
end
+ def test_ensure_that_database_option_is_passed_to_app_generator
+ run_generator [destination_root, "--database", "postgresql"]
+ assert_file "test/dummy/config/database.yml", /postgres/
+ end
+
+ def test_ensure_that_javascript_option_is_passed_to_app_generator
+ run_generator [destination_root, "--javascript", "jquery"]
+ assert_file "test/dummy/public/javascripts/jquery.js"
+ end
+
+ def test_ensure_that_skip_javascript_option_is_passed_to_app_generator
+ run_generator [destination_root, "--skip_javascript"]
+ assert_no_file "test/dummy/public/javascripts/prototype.js"
+ end
+
def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match /It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])

0 comments on commit 46fdb31

Please sign in to comment.