aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-06-18 17:01:19 -0400
committerGitHub <noreply@github.com>2018-06-18 17:01:19 -0400
commit433a3122697e41bb46c4f072d2d8223233af5dd4 (patch)
tree77ea3d6eceb183d6fb891027b9bc71ab7133b1c4
parentb43aa17b8acfa85b2ddfcf71ca7ba0f876a6d4db (diff)
parent1aace5e2cc7784799c2b91fb3feb2bd285c0e628 (diff)
downloadrails-433a3122697e41bb46c4f072d2d8223233af5dd4.tar.gz
rails-433a3122697e41bb46c4f072d2d8223233af5dd4.tar.bz2
rails-433a3122697e41bb46c4f072d2d8223233af5dd4.zip
Merge pull request #33152 from bogdanvlviv/fix-ruby-version-file
Fix Ruby version in `.ruby-version`
-rw-r--r--railties/lib/rails/generators/rails/app/templates/ruby-version.tt2
-rw-r--r--railties/test/generators/app_generator_test.rb8
2 files changed, 8 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/ruby-version.tt b/railties/lib/rails/generators/rails/app/templates/ruby-version.tt
index 19f0d7f202..bac1339923 100644
--- a/railties/lib/rails/generators/rails/app/templates/ruby-version.tt
+++ b/railties/lib/rails/generators/rails/app/templates/ruby-version.tt
@@ -1 +1 @@
-<%= "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>
+<%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 3cb7d66bbb..d8e9ae3369 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -891,7 +891,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_match(/ruby '#{RUBY_VERSION}'/, content)
end
assert_file ".ruby-version" do |content|
- assert_match(/#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}/, content)
+ if ENV["RBENV_VERSION"]
+ assert_match(/#{ENV["RBENV_VERSION"]}/, content)
+ elsif ENV["rvm_ruby_string"]
+ assert_match(/#{ENV["rvm_ruby_string"]}/, content)
+ else
+ assert_match(/#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}/, content)
+ end
end
end