Merge pull request #28541 from ota42y/fix/gemfile_generator_fix

ignore system test gems on Gemfile when execute with --skip-test option
This commit is contained in:
Eileen M. Uchitelle 2017-03-27 08:25:53 -04:00 committed by GitHub
commit 255ef67d5c
4 changed files with 30 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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)