Skip to content

Instantly share code, notes, and snippets.

@luizpicolo
Forked from ivanoats/.railsrc
Created January 14, 2020 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizpicolo/619099f2652e208ee111c6354a0e8db1 to your computer and use it in GitHub Desktop.
Save luizpicolo/619099f2652e208ee111c6354a0e8db1 to your computer and use it in GitHub Desktop.
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres

Here's my super fun and easy rails setup

Usage "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
#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 git@github.com:#{ENV['USER']}/#{app_path}.git"
git push: "origin master"
#TODO
#add custom error pages
#continue to add gems and config the
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment