Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
*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 /
# .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'
gem_group :test do
gem 'minitest-rails-capybara'
run "bundle install"
#install minitest test_helper
#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 / 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'
run "rm README.rdoc"
run "touch"
#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']}' -d '{\"name\":\"#{app_path}\"}'"
git remote: "add origin{ENV['USER']}/#{app_path}.git"
git push: "origin master"
#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
You can’t perform that action at this time.