Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Updated version constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
mkevinosullivan committed Feb 22, 2021
1 parent ad87112 commit faf7d46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/project_types/rails/commands/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lib/project_types/rails/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 9 additions & 4 deletions test/project_types/rails/commands/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit faf7d46

Please sign in to comment.