Last active
August 11, 2020 09:33
-
-
Save gringocl/8480696 to your computer and use it in GitHub Desktop.
*Usagage "rails new my_cool_app -m path/to/template.rb
*My template.rb file for taking care of some of the boring basic configuration of a new rails app, create the repo and push it to Github.
*Using mini-test / capybara / guard / spring / postgres.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .railsrc | |
-B #Skip Bundle | |
-T #Skip Test-Unit | |
-d postgresql #Use postgres | |
# template.rb | |
#add guard-minitest and spring to dev | |
gem_group :development do | |
gem 'guard-minitest' | |
gem 'spring' | |
end | |
gem_group :test do | |
gem 'minitest-rails-capybara' | |
end | |
run "bundle install" | |
#install minitest test_helper | |
generate('mini_test:install') | |
#config minitest Spec DSL and Fixtures defaults | |
environment "config.generators do |g|\n g.test_framework :mini_test, spec: true, fixture: true\n end" | |
#uncomment minitest-rails-capybara and pride in test_helper | |
# sed -i in osx needs to have a file explicitly named as backup | |
# hence the blank '' | |
run "sed -i '' '8 s/^ *# //' test/test_helper.rb" | |
run "sed -i '' '11 s/^ *# //' test/test_helper.rb" | |
#create postgres DB for postgress.app / Adds default user to username for | |
#development and test | |
run "psql -c 'CREATE DATABASE #{app_path}_development;'" | |
run "psql -c 'CREATE DATABASE #{app_path}_test;'" | |
run "sed -i '' '1,54 s/username: #{app_path}/username: #{ENV['USER']}/' config/database.yml" | |
#Add minitest features to Rake task | |
run %q^echo 'MiniTest::Rails::Testing.default_tasks << "features"' >> Rakefile^ | |
#install guard-minitest | |
run "bundel exec guard init minitest" | |
#uncomment and comment Guardfile / Add spring: 'rake test' to file | |
run "sed -i '' '6,8 s/^/#/' Guardfile" | |
run "sed -i '' '14,20 s/^ *#//' Guardfile" | |
run "sed -i '' '11,13 s/^ *#//' Guardfile" | |
run %Q{sed -i '' "s/^guard :minitest do/guard :minitest, spring: 'rake test' do/" Guardfile} | |
#Add spring to bins and start spring | |
run 'spring binstub --all' | |
#Fix README.md | |
run "rm README.rdoc" | |
run "touch README.md" | |
#Initialize local Git repository and Initial Commit | |
git :init | |
git add: "." | |
git commit: "-a -m 'Initial commit'" | |
#Create remote repo on Github and push | |
run "curl -u '#{ENV['USER']}' https://api.github.com/user/repos -d '{\"name\":\"#{app_path}\"}'" | |
git remote: "add origin [email protected]:#{ENV['USER']}/#{app_path}.git" | |
git push: "origin master" | |
#TODO | |
#add custom error pages | |
#continue to add gems and config them |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment