diff --git a/.ruby-version b/.ruby-version index eca690e73..acf9bf09d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.5 +3.2.2 \ No newline at end of file diff --git a/lib/suspenders/app_builder.rb b/lib/suspenders/app_builder.rb index 8beb5547f..f867603d2 100644 --- a/lib/suspenders/app_builder.rb +++ b/lib/suspenders/app_builder.rb @@ -155,7 +155,7 @@ def replace_gemfile end def ruby_version - create_file ".ruby-version", "#{Suspenders::RUBY_VERSION}\n" + create_file ".ruby-version", "#{::RUBY_VERSION}\n" end def configure_i18n_for_missing_translations diff --git a/lib/suspenders/version.rb b/lib/suspenders/version.rb index 606b536ea..4cf6b0e20 100644 --- a/lib/suspenders/version.rb +++ b/lib/suspenders/version.rb @@ -1,8 +1,9 @@ module Suspenders RAILS_VERSION = "~> 7.0.0".freeze - RUBY_VERSION = IO - .read("#{File.dirname(__FILE__)}/../../.ruby-version") - .strip - .freeze + + minimum_ruby_version = "3.0.5" + maximum_ruby_version = Pathname(__dir__).join("../../.ruby-version").read.strip + + RUBY_VERSION_RANGE = [minimum_ruby_version, maximum_ruby_version].freeze VERSION = "20230113.0".freeze end diff --git a/spec/features/new_project_spec.rb b/spec/features/new_project_spec.rb index be19738b0..f232b958e 100644 --- a/spec/features/new_project_spec.rb +++ b/spec/features/new_project_spec.rb @@ -11,7 +11,7 @@ it "uses custom Gemfile" do gemfile_file = IO.read("#{project_path}/Gemfile") expect(gemfile_file).to match( - /^ruby "#{Suspenders::RUBY_VERSION}"$/o + /^ruby "#{RUBY_VERSION}"$/o ) expect(gemfile_file).to match( /^gem "rails", "#{Suspenders::RAILS_VERSION}"$/o @@ -34,8 +34,8 @@ end end - it "creates .ruby-version from Suspenders .ruby-version" do - ruby_version_file = IO.read("#{project_path}/.ruby-version") + it "creates .ruby-version with the running ruby version" do + ruby_version_file = project_path.join(".ruby-version").read expect(ruby_version_file).to eq "#{RUBY_VERSION}\n" end diff --git a/suspenders.gemspec b/suspenders.gemspec index dde3b1cef..b9d3ad069 100644 --- a/suspenders.gemspec +++ b/suspenders.gemspec @@ -3,7 +3,9 @@ require "suspenders/version" require "date" Gem::Specification.new do |s| - s.required_ruby_version = ">= #{Suspenders::RUBY_VERSION}" + minimum, maximum = Suspenders::RUBY_VERSION_RANGE + + s.required_ruby_version = [">= #{minimum}", "<= #{maximum}"] s.required_rubygems_version = ">= 3.0.0" s.authors = ["thoughtbot"] diff --git a/templates/Gemfile.erb b/templates/Gemfile.erb index 5442decb1..26575ed40 100644 --- a/templates/Gemfile.erb +++ b/templates/Gemfile.erb @@ -5,7 +5,7 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end -ruby "<%= Suspenders::RUBY_VERSION %>" +ruby <%= RUBY_VERSION.inspect %> <% if options[:api] %> gem "sprockets", "< 4"