Permalink
Browse files

Merge pull request #30016 from albertoalmagro/set-ruby-version-in-gem…

…file-and-ruby-version-by-default

Set Ruby version in Gemfile and .ruby-version by default
  • Loading branch information...
guilleiguaran committed Jul 31, 2017
2 parents 0f24588 + fd7f978 commit 0d58e7e478e79c2d6b2a39a4444d2a17a903b2a6
View
@@ -1,3 +1,9 @@
* Add `ruby x.x.x` version to `Gemfile` and create `.ruby-version`
root file containing current Ruby version when new Rails applications are
created.
*Alberto Almagro*
* Support `-` as a platform-agnostic way to run a script from stdin with
`rails runner`
@@ -49,6 +49,10 @@ def readme
copy_file "README.md", "README.md"
end
def ruby_version
template "ruby-version", ".ruby-version"
end
def gemfile
template "Gemfile"
end
@@ -242,6 +246,7 @@ def initialize(*args)
def create_root_files
build(:readme)
build(:rakefile)
build(:ruby_version)
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
@@ -1,5 +1,6 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby <%= "'#{RUBY_VERSION}'" %>
<% gemfile_entries.each do |gem| -%>
<% if gem.comment -%>
@@ -0,0 +1 @@
<%= RUBY_VERSION -%>
@@ -4,6 +4,7 @@
DEFAULT_APP_FILES = %w(
.gitignore
.ruby-version
README.md
Gemfile
Rakefile
@@ -805,6 +806,17 @@ def test_gitignore_when_non_sqlite3_db
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
run_generator [destination_root]
assert_directory ".git"

0 comments on commit 0d58e7e

Please sign in to comment.