aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/plugin_new_generator_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators/plugin_new_generator_test.rb')
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb44
1 files changed, 42 insertions, 2 deletions
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index 58740978aa..0a235b56d5 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -58,6 +58,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_file "test/integration/navigation_test.rb", /ActionDispatch::IntegrationTest/
end
+ def test_generating_test_files_in_full_mode_without_unit_test_files
+ run_generator [destination_root, "-T", "--full"]
+
+ assert_no_directory "test/integration/"
+ assert_no_file "test"
+ assert_no_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile")))
+ end
+
def test_ensure_that_plugin_options_are_not_passed_to_app_generator
FileUtils.cd(Rails.root)
assert_no_match(/It works from file!.*It works_from_file/, run_generator([destination_root, "-m", "lib/template.rb"]))
@@ -82,6 +90,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_file "bukkits.gemspec", /mysql/
end
+ def test_dont_generate_development_dependency
+ run_generator [destination_root, "--skip-active-record"]
+
+ assert_file "bukkits.gemspec" do |contents|
+ assert_no_match(/s.add_development_dependency "sqlite3"/, contents)
+ end
+ end
+
def test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given
run_generator [destination_root, "--skip-active-record"]
assert_file "test/dummy/config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
@@ -269,6 +285,32 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
def test_skipping_gemspec
run_generator [destination_root, "--skip-gemspec"]
assert_no_file "bukkits.gemspec"
+ assert_file "Gemfile" do |contents|
+ assert_no_match('gemspec', contents)
+ assert_match(/gem "rails", "~> #{Rails::VERSION::STRING}"/, contents)
+ assert_match(/group :development do\n gem "sqlite3"\nend/, contents)
+ assert_no_match(/# gem "jquery-rails"/, contents)
+ end
+ end
+
+ def test_skipping_gemspec_in_full_mode
+ run_generator [destination_root, "--skip-gemspec", "--full"]
+ assert_no_file "bukkits.gemspec"
+ assert_file "Gemfile" do |contents|
+ assert_no_match('gemspec', contents)
+ assert_match(/gem "rails", "~> #{Rails::VERSION::STRING}"/, contents)
+ assert_match(/group :development do\n gem "sqlite3"\nend/, contents)
+ assert_match(/# gem "jquery-rails"/, contents)
+ assert_no_match(/# jquery-rails is used by the dummy application\ngem "jquery-rails"/, contents)
+ end
+ end
+
+ def test_skipping_gemspec_in_full_mode_with_javascript_option
+ run_generator [destination_root, "--skip-gemspec", "--full", "--javascript=prototype"]
+ assert_file "Gemfile" do |contents|
+ assert_match(/# gem "prototype-rails"/, contents)
+ assert_match(/# jquery-rails is used by the dummy application\ngem "jquery-rails"/, contents)
+ end
end
def test_creating_plugin_in_app_directory_adds_gemfile_entry
@@ -303,12 +345,10 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
protected
-
def action(*args, &block)
silence(:stdout){ generator.send(*args, &block) }
end
-protected
def default_files
::DEFAULT_PLUGIN_FILES
end