Revert "Revert "Set Ruby version in Gemfile and .ruby-version by default""

This reverts commit a8f59044.

See discussion on https://github.com/rails/rails/pull/30016.
上级 a8f59044
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
*Yuji Yaginuma* *Yuji Yaginuma*
* Add `ruby x.x.x` version to `Gemfile` and create `.ruby-version`
root file containing the current Ruby version when new Rails applications are
created.
*Alberto Almagro*
* Support `-` as a platform-agnostic way to run a script from stdin with * Support `-` as a platform-agnostic way to run a script from stdin with
`rails runner` `rails runner`
......
...@@ -49,6 +49,10 @@ def readme ...@@ -49,6 +49,10 @@ def readme
copy_file "README.md", "README.md" copy_file "README.md", "README.md"
end end
def ruby_version
template "ruby-version", ".ruby-version"
end
def gemfile def gemfile
template "Gemfile" template "Gemfile"
end end
...@@ -253,6 +257,7 @@ def initialize(*args) ...@@ -253,6 +257,7 @@ def initialize(*args)
def create_root_files def create_root_files
build(:readme) build(:readme)
build(:rakefile) build(:rakefile)
build(:ruby_version)
build(:configru) build(:configru)
build(:gitignore) unless options[:skip_git] build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile] build(:gemfile) unless options[:skip_gemfile]
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
DEFAULT_APP_FILES = %w( DEFAULT_APP_FILES = %w(
.gitignore .gitignore
.ruby-version
README.md README.md
Gemfile Gemfile
Rakefile Rakefile
...@@ -808,6 +809,17 @@ def test_gitignore_when_non_sqlite3_db ...@@ -808,6 +809,17 @@ def test_gitignore_when_non_sqlite3_db
end end
end end
def test_inclusion_of_ruby_version
run_generator
assert_file "Gemfile" do |content|
assert_match(/ruby '#{RUBY_VERSION}'/, content)
end
assert_file ".ruby-version" do |content|
assert_match(/#{RUBY_VERSION}/, content)
end
end
def test_version_control_initializes_git_repo def test_version_control_initializes_git_repo
run_generator [destination_root] run_generator [destination_root]
assert_directory ".git" assert_directory ".git"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册