From faf7d4652d4bb2d082afb3b7749f3902dfb9405c Mon Sep 17 00:00:00 2001 From: Kevin O'Sullivan Date: Thu, 28 Jan 2021 17:05:52 -0500 Subject: [PATCH] Updated version constraints --- lib/project_types/rails/commands/create.rb | 6 +++--- lib/project_types/rails/gem.rb | 2 +- test/project_types/rails/commands/create_test.rb | 13 +++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/project_types/rails/commands/create.rb b/lib/project_types/rails/commands/create.rb index 4fcc17687e..1ec4dad7d5 100644 --- a/lib/project_types/rails/commands/create.rb +++ b/lib/project_types/rails/commands/create.rb @@ -29,7 +29,7 @@ def call(args, _name) ruby_version = Ruby.version(@ctx) @ctx.abort(@ctx.message('rails.create.error.invalid_ruby_version')) unless - ruby_version.satisfies?('~>2.5') || ruby_version.satisfies?('<3.1') + ruby_version.satisfies?('~>2.5') || ruby_version.satisfies?('~>3.0.0') check_node check_yarn @@ -113,7 +113,7 @@ def check_yarn end def build(name, db) - @ctx.abort(@ctx.message('rails.create.error.install_failure', 'rails')) unless install_gem('rails') + @ctx.abort(@ctx.message('rails.create.error.install_failure', 'rails')) unless install_gem('rails', '<6.1') @ctx.abort(@ctx.message('rails.create.error.install_failure', 'bundler ~>2.0')) unless install_gem('bundler', '~>2.0') @@ -136,7 +136,7 @@ def build(name, db) @ctx.puts(@ctx.message('rails.create.adding_shopify_gem')) File.open(File.join(@ctx.root, 'Gemfile'), 'a') do |f| - f.puts "\ngem 'shopify_app', '>=11.3.0'" + f.puts "\ngem 'shopify_app', '>=17.0.3'" end CLI::UI::Frame.open(@ctx.message('rails.create.running_bundle_install')) do syscall(%w(bundle install)) diff --git a/lib/project_types/rails/gem.rb b/lib/project_types/rails/gem.rb index ad1b65dffc..12bd2b1a22 100644 --- a/lib/project_types/rails/gem.rb +++ b/lib/project_types/rails/gem.rb @@ -99,7 +99,7 @@ def gem_satisfies_version?(path) # there was a specific version given during new(), so # check version of gem found to determine match require 'semantic/semantic' - found_version, _ = path.match(%r{/#{Regexp.quote(name)}-([\d\.]+)})&.captures + found_version, _ = path.match(%r{/#{Regexp.quote(name)}-(\d\.\d\.\d)})&.captures found_version.nil? ? false : Semantic::Version.new(found_version).satisfies?(version) else # otherwise ignore the actual version number, diff --git a/test/project_types/rails/commands/create_test.rb b/test/project_types/rails/commands/create_test.rb index de4d82cfb0..f51e4e9ea9 100644 --- a/test/project_types/rails/commands/create_test.rb +++ b/test/project_types/rails/commands/create_test.rb @@ -31,6 +31,11 @@ def test_will_abort_if_bad_ruby assert_raises ShopifyCli::Abort do perform_command end + + Ruby.expects(:version).returns(Semantic::Version.new('3.1.0')) + assert_raises ShopifyCli::Abort do + perform_command + end end def test_can_create_new_app @@ -40,7 +45,7 @@ def test_can_create_new_app Gem.stubs(:gem_home).returns(gem_path) Ruby.expects(:version).returns(Semantic::Version.new('2.5.0')) - Gem.expects(:install).with(@context, 'rails', nil).returns(true) + Gem.expects(:install).with(@context, 'rails', '<6.1').returns(true) Gem.expects(:install).with(@context, 'bundler', '~>2.0').returns(true) expect_command(%W(#{gem_path}/bin/rails new --skip-spring --database=sqlite3 test-app)) expect_command(%W(#{gem_path}/bin/bundle install), @@ -92,7 +97,7 @@ def test_can_create_new_app_with_db_flag Gem.stubs(:gem_home).returns(gem_path) Ruby.expects(:version).returns(Semantic::Version.new('2.5.0')) - Gem.expects(:install).with(@context, 'rails', nil).returns(true) + Gem.expects(:install).with(@context, 'rails', '<6.1').returns(true) Gem.expects(:install).with(@context, 'bundler', '~>2.0').returns(true) expect_command(%W(#{gem_path}/bin/rails new --skip-spring --database=postgresql test-app)) expect_command(%W(#{gem_path}/bin/bundle install), @@ -140,7 +145,7 @@ def test_can_create_new_app_with_rails_opts_flag Gem.stubs(:gem_home).returns(gem_path) Ruby.expects(:version).returns(Semantic::Version.new('2.5.0')) - Gem.expects(:install).with(@context, 'rails', nil).returns(true) + Gem.expects(:install).with(@context, 'rails', '<6.1').returns(true) Gem.expects(:install).with(@context, 'bundler', '~>2.0').returns(true) expect_command(%W(#{gem_path}/bin/rails new --skip-spring --database=sqlite3 --edge -J test-app)) expect_command(%W(#{gem_path}/bin/bundle install), @@ -189,7 +194,7 @@ def test_create_fails_if_path_exists Gem.stubs(:gem_home).returns(gem_path) Ruby.expects(:version).returns(Semantic::Version.new('2.5.0')) - Gem.expects(:install).with(@context, 'rails', nil).returns(true) + Gem.expects(:install).with(@context, 'rails', '<6.1').returns(true) Gem.expects(:install).with(@context, 'bundler', '~>2.0').returns(true) Dir.stubs(:exist?).returns(true)