Skip to content

Commit e8efa75

Browse files
authored
Merge pull request #562 from rails/flavorjones/559-skip-system-test
Gracefully handle --skip-system-test
2 parents ed7d059 + b6cb944 commit e8efa75

File tree

2 files changed

+40
-20
lines changed

2 files changed

+40
-20
lines changed

lib/generators/test_unit/scaffold/scaffold_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module TestUnit # :nodoc:
44
module Generators # :nodoc:
55
class ScaffoldGenerator < Base # :nodoc:
66
def fix_system_test
7-
if turbo_defined?
7+
if turbo_defined? && options[:system_tests]
88
gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
99
/(click_on.*Destroy this.*)$/,
1010
"accept_confirm { \\1 }"

test/integration/user_install_test.sh

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,41 @@ bundle remove actionmailer || true
1111
bundle remove rails || true
1212
bundle add rails --skip-install ${RAILSOPTS:-}
1313
bundle install --prefer-local
14+
bundle exec rails -v
1415

1516
# do our work a directory with spaces in the name (#176, #184)
1617
rm -rf "My Workspace"
1718
mkdir "My Workspace"
1819
pushd "My Workspace"
1920

20-
# create a rails app
21-
bundle exec rails -v
21+
function prepare_deps {
22+
# make sure to use the same version of rails (e.g., install from git source if necessary)
23+
bundle remove rails --skip-install
24+
bundle add rails --skip-install ${RAILSOPTS:-}
25+
26+
# use the tailwindcss-rails under test
27+
bundle add tailwindcss-rails --skip-install --path="../.."
28+
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-}
29+
bundle install --prefer-local
30+
bundle show --paths | fgrep tailwind
31+
bundle binstubs --all
32+
}
33+
34+
function install_tailwindcss {
35+
# install tailwindcss
36+
bin/rails tailwindcss:install
37+
38+
# TEST: tailwind was installed correctly
39+
grep -q "<main class=\"container" app/views/layouts/application.html.erb
40+
test -a app/assets/tailwind/application.css
41+
}
42+
43+
# Application variation #1 ----------------------------------------
2244
bundle exec rails new test-install --skip-bundle
2345
pushd test-install
2446

25-
# make sure to use the same version of rails (e.g., install from git source if necessary)
26-
bundle remove rails --skip-install
27-
bundle add rails --skip-install ${RAILSOPTS:-}
28-
29-
# use the tailwindcss-rails under test
30-
bundle add tailwindcss-rails --skip-install --path="../.."
31-
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-}
32-
bundle install --prefer-local
33-
bundle show --paths | fgrep tailwind
34-
bundle binstubs --all
35-
36-
# install tailwindcss
37-
bin/rails tailwindcss:install
38-
39-
# TEST: tailwind was installed correctly
40-
grep -q "<main class=\"container" app/views/layouts/application.html.erb
41-
test -a app/assets/tailwind/application.css
47+
prepare_deps
48+
install_tailwindcss
4249

4350
# TEST: rake tasks don't exec (#188)
4451
cat <<EOF >> Rakefile
@@ -73,4 +80,17 @@ grep -q "py-2" app/assets/builds/tailwind.css
7380
# TEST: contents include application.css directives
7481
grep -q "#abc12399" app/assets/builds/tailwind.css
7582

83+
# Application variation #2 ----------------------------------------
84+
popd
85+
bundle exec rails new test-install2 --skip-bundle --skip-system-test
86+
pushd test-install2
87+
88+
prepare_deps
89+
install_tailwindcss
90+
91+
# TEST: presence of the generated file
92+
# TEST: nothing blew up without system tests, https://github.com/rails/tailwindcss-rails/issues/559
93+
bin/rails generate scaffold post title:string body:text published:boolean
94+
grep -q "Show" app/views/posts/index.html.erb
95+
7696
echo "OK"

0 commit comments

Comments
 (0)