Skip to content

Commit

Permalink
Generate Gemfile entry with version constraint
Browse files Browse the repository at this point in the history
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 `3.0.0`.

[v0.2.4]: https://github.com/thoughtbot/suspenders/tree/v0.2.4
  • Loading branch information
seanpdoyle committed Dec 6, 2024
1 parent a4a4af0 commit 000a705
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/install/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def apply_template!
if ARGV.include?("--suspenders-main")
gem "suspenders", github: "thoughtbot/suspenders", branch: "main"
else
gem "suspenders"
gem "suspenders", "~> 3"
end
end

Expand Down
8 changes: 8 additions & 0 deletions test/generators/suspenders/install/web_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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", "~> 3"/
end

test "raises if API only application" do
within_api_only_app do
assert_raises Suspenders::Generators::APIAppUnsupported::Error do
Expand Down

0 comments on commit 000a705

Please sign in to comment.