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

Commit

Permalink
Merge pull request #2172 from Shopify/fix-ruby-version-check
Browse files Browse the repository at this point in the history
Fix ruby version check
  • Loading branch information
gonzaloriestra authored Mar 23, 2022
2 parents 54c9672 + 61c5755 commit 76ecc68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h

### Fixed
* [#1874](https://github.com/Shopify/shopify-cli/pull/1874): Make ngrok errors more robust and helpful
* [#2172](https://github.com/Shopify/shopify-cli/pull/2172): Fix Ruby check for Rails app creation

## Version 2.15.0

Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_cli/services/app/create/rails_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def check_dependencies
end

def check_ruby
ruby_version = Environment.ruby_version(context)
ruby_version = Environment.ruby_version(context: context)
return if ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.1.0")
context.abort(context.message("core.app.create.rails.error.invalid_ruby_version"))
end
Expand Down
14 changes: 7 additions & 7 deletions test/shopify-cli/services/app/create/rails_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def setup
end

def test_will_abort_if_bad_ruby
Environment.expects(:ruby_version).returns(Semantic::Version.new("2.3.7"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.3.7"))
assert_raises ShopifyCLI::Abort do
call_service
end

Environment.expects(:ruby_version).returns(Semantic::Version.new("3.1.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("3.1.0"))
assert_raises ShopifyCLI::Abort do
call_service
end
Expand All @@ -50,7 +50,7 @@ def test_can_create_new_app_with_rails_7
gem_path = create_gem_path_and_binaries
::Rails::Gem.stubs(:gem_home).returns(gem_path)

Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
expect_rails_version("7.0.1")
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_can_create_new_app
gem_path = create_gem_path_and_binaries
::Rails::Gem.stubs(:gem_home).returns(gem_path)

Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
expect_rails_version("6.1.4")
Expand Down Expand Up @@ -154,7 +154,7 @@ def test_can_create_new_app_with_db_flag
gem_path = create_gem_path_and_binaries
::Rails::Gem.stubs(:gem_home).returns(gem_path)

Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
expect_rails_version("6.1.4")
Expand Down Expand Up @@ -203,7 +203,7 @@ def test_can_create_new_app_with_rails_opts_flag
gem_path = create_gem_path_and_binaries
::Rails::Gem.stubs(:gem_home).returns(gem_path)

Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
expect_rails_version("6.1.4")
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_create_fails_if_path_exists
gem_path = create_gem_path_and_binaries
::Rails::Gem.stubs(:gem_home).returns(gem_path)

Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
Dir.stubs(:exist?).returns(true)
Expand Down

0 comments on commit 76ecc68

Please sign in to comment.