Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rails template
#
# 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
You can’t perform that action at this time.