From b181e38629cfd6d92f9af901e2a50c1ad743cc47 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Fri, 6 Dec 2024 11:51:15 -0500 Subject: [PATCH] Generate Gemfile entry with version constraint When generating a new application by loading the template over HTTP, specifying `gem "suspenders"` without a version constraint results in the resolution of an extremely outdated version ([v0.2.4][]). When omitting the `--suspenders-main` argument, include a version constraint to use a version that is at least `20240101`. [v0.2.4]: https://github.com/thoughtbot/suspenders/tree/v0.2.4 --- lib/install/web.rb | 2 +- test/generators/suspenders/install/web_generator_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/install/web.rb b/lib/install/web.rb index 1796f474..c942aefd 100644 --- a/lib/install/web.rb +++ b/lib/install/web.rb @@ -28,7 +28,7 @@ def apply_template! if ARGV.include?("--suspenders-main") gem "suspenders", github: "thoughtbot/suspenders", branch: "main" else - gem "suspenders" + gem "suspenders", "> 20240101" end end diff --git a/test/generators/suspenders/install/web_generator_test.rb b/test/generators/suspenders/install/web_generator_test.rb index b2740732..6a0892c4 100644 --- a/test/generators/suspenders/install/web_generator_test.rb +++ b/test/generators/suspenders/install/web_generator_test.rb @@ -12,6 +12,14 @@ class WebGeneratorTest < Rails::Generators::TestCase setup :prepare_destination teardown :restore_destination + test "generates Gemfile entry with version constraint" do + with_database "postgresql" do + run_generator + end + + assert_file "Gemfile", /gem "suspenders", "> 20240101"/ + end + test "raises if API only application" do within_api_only_app do assert_raises Suspenders::Generators::APIAppUnsupported::Error do