diff options
Diffstat (limited to 'railties')
6 files changed, 36 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/destroy/destroy_command.rb b/railties/lib/rails/commands/destroy/destroy_command.rb index 794673851d..281732a936 100644 --- a/railties/lib/rails/commands/destroy/destroy_command.rb +++ b/railties/lib/rails/commands/destroy/destroy_command.rb @@ -5,6 +5,9 @@ module Rails class DestroyCommand < Base # :nodoc: no_commands do def help + require_application_and_environment! + load_generators + Rails::Generators.help self.class.command_name end end diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index fbb6b5039c..8c3d74ad80 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -413,6 +413,10 @@ module Rails !options[:skip_spring] && !options.dev? && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin") end + def depends_on_system_test? + !(options[:skip_system_test] || options[:skip_test] || options[:api]) + end + def depend_on_listen? !options[:skip_listen] && os_supports_listen_out_of_the_box? end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index b32878cf0b..66e72f8cdc 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -275,7 +275,7 @@ module Rails end def create_system_test_files - build(:system_test) unless options[:skip_system_test] || options[:skip_test] || options[:api] + build(:system_test) if depends_on_system_test? end def create_tmp_files diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index ab4aa04fff..06f0dd6d6d 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -32,7 +32,7 @@ end group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] - <%- unless options.skip_system_test? || options.api? -%> + <%- if depends_on_system_test? -%> # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13.0' gem 'selenium-webdriver' diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index ee0d697599..fe581db286 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -189,6 +189,9 @@ module ApplicationTests FileUtils.cd(rails_root) do output = `bin/rails generate --help` assert_no_match "active_record:migration", output + + output = `bin/rails destroy --help` + assert_no_match "active_record:migration", output end end end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index f6cdbd34fe..8e18162df7 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -436,6 +436,30 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "Gemfile", /^# gem 'redis'/ end + def test_generator_if_skip_test_is_given + run_generator [destination_root, "--skip-test"] + assert_file "Gemfile" do |content| + assert_no_match(/capybara/, content) + assert_no_match(/selenium-webdriver/, content) + end + end + + def test_generator_if_skip_system_test_is_given + run_generator [destination_root, "--skip_system_test"] + assert_file "Gemfile" do |content| + assert_no_match(/capybara/, content) + assert_no_match(/selenium-webdriver/, content) + end + end + + def test_generator_if_api_is_given + run_generator [destination_root, "--api"] + assert_file "Gemfile" do |content| + assert_no_match(/capybara/, content) + assert_no_match(/selenium-webdriver/, content) + end + end + def test_inclusion_of_javascript_runtime run_generator if defined?(JRUBY_VERSION) |