Created
January 7, 2013 15:09
-
-
Save zhangsen/4475660 to your computer and use it in GitHub Desktop.
rails template
This file contains hidden or 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
# | |
# Rails template: rspec, guard, spork, libnotify, capybara | |
# $ rails -T -m <path-to-me> | |
gem_group :development, :test do | |
gem 'rspec-rails' | |
gem 'guard-rspec' | |
gem 'guard-spork' | |
gem 'spork' | |
end | |
gem_group :test do | |
gem 'capybara', '1.1.2' | |
gem 'rb-inotify' | |
gem 'libnotify' | |
end | |
run 'bundle install' | |
# rspec | |
generate 'rspec:install' | |
# spork | |
run 'spork rspec --bootstrap' | |
def indent(s) | |
(s.split("\n").map { |ln| ln.length > 0 ? " " + ln : ln} ).join("\n") | |
end | |
# spork - spec/spec_helper.rb | |
File.open('spec/spec_helper.rb') do |f| | |
t = f.read.match(/(#\sThis file is copied to.*)/m)[1] | |
gsub_file 'spec/spec_helper.rb', /Spork.prefork do.*/m, <<-EOF | |
Spork.prefork do | |
#{indent(t)} | |
end | |
Spork.each_run do | |
load "\#{::Rails.root}/config/routes.rb" | |
end | |
EOF | |
end | |
# guard | |
run 'guard init spork' | |
run 'guard init rspec' | |
# guard: libnotify settings | |
inject_into_file 'Guardfile', | |
"notification :libnotify, :transient => true\n\n", | |
:before => /^guard 'spork'.*/ | |
# guard: --drb | |
gsub_file 'Guardfile', | |
"guard 'rspec', do", | |
"guard 'rspec', :cli => '--drb' do" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment