Skip to content

Gracefully handle --skip-system-test #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/generators/test_unit/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module TestUnit # :nodoc:
module Generators # :nodoc:
class ScaffoldGenerator < Base # :nodoc:
def fix_system_test
if turbo_defined?
if turbo_defined? && options[:system_tests]
gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
/(click_on.*Destroy this.*)$/,
"accept_confirm { \\1 }"
Expand Down
58 changes: 39 additions & 19 deletions test/integration/user_install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,41 @@ bundle remove actionmailer || true
bundle remove rails || true
bundle add rails --skip-install ${RAILSOPTS:-}
bundle install --prefer-local
bundle exec rails -v

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

# create a rails app
bundle exec rails -v
function prepare_deps {
# make sure to use the same version of rails (e.g., install from git source if necessary)
bundle remove rails --skip-install
bundle add rails --skip-install ${RAILSOPTS:-}

# use the tailwindcss-rails under test
bundle add tailwindcss-rails --skip-install --path="../.."
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-}
bundle install --prefer-local
bundle show --paths | fgrep tailwind
bundle binstubs --all
}

function install_tailwindcss {
# install tailwindcss
bin/rails tailwindcss:install

# TEST: tailwind was installed correctly
grep -q "<main class=\"container" app/views/layouts/application.html.erb
test -a app/assets/tailwind/application.css
}

# Application variation #1 ----------------------------------------
bundle exec rails new test-install --skip-bundle
pushd test-install

# make sure to use the same version of rails (e.g., install from git source if necessary)
bundle remove rails --skip-install
bundle add rails --skip-install ${RAILSOPTS:-}

# use the tailwindcss-rails under test
bundle add tailwindcss-rails --skip-install --path="../.."
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-}
bundle install --prefer-local
bundle show --paths | fgrep tailwind
bundle binstubs --all

# install tailwindcss
bin/rails tailwindcss:install

# TEST: tailwind was installed correctly
grep -q "<main class=\"container" app/views/layouts/application.html.erb
test -a app/assets/tailwind/application.css
prepare_deps
install_tailwindcss

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

# Application variation #2 ----------------------------------------
popd
bundle exec rails new test-install2 --skip-bundle --skip-system-test
pushd test-install2

prepare_deps
install_tailwindcss

# TEST: presence of the generated file
# TEST: nothing blew up without system tests, https://github.com/rails/tailwindcss-rails/issues/559
bin/rails generate scaffold post title:string body:text published:boolean
grep -q "Show" app/views/posts/index.html.erb

echo "OK"
Loading