Skip to content

Instantly share code, notes, and snippets.

@zhengjia
Forked from Lytol/ultemplate.rb
Created September 24, 2010 04:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhengjia/594847 to your computer and use it in GitHub Desktop.
Save zhengjia/594847 to your computer and use it in GitHub Desktop.
# Rails application template for Rails 3 + Git + haml + JQuery + Rspec + Cucumber + Capybara + FactoryGirl
# by Brian Smith <bsmith@swig505.com>
# Create a default README
remove_file "README"
file "README.md", <<-EOF
#{app_const}
#{"=" * app_const.length}
TODO: description
Getting Started
---------------
TODO: how to get app running
EOF
# Remove index.html and rails.png
remove_file "public/index.html"
remove_file "public/images/rails.png"
# Create default Gemfile
remove_file "Gemfile"
file "Gemfile", <<-EOF
source "http://rubygems.org"
gem "rails", "3.0.0"
gem "pg"
gem "haml"
group :development, :test do
gem "capybara"
gem "cucumber"
gem "cucumber-rails"
gem "rspec-rails", ">= 2.0.0.beta.22"
gem "factory_girl_rails"
end
EOF
run "bundle install"
# Generator config
application <<-EOF
config.generators do |g|
g.orm :active_record
g.template_engine :haml
g.test_framework :rspec
g.fixture_replacement :factory_girl
g.helper false
end
EOF
# Database
remove_file "config/database.yml"
database_config = <<-EOF
development:
adapter: postgresql
encoding: unicode
database: #{app_name}_dev
test:
adapter: postgresql
encoding: unicode
database: #{app_name}_test
EOF
file "config/database.yml", database_config
file "config/database.yml-example", database_config
# Rspec
run "rm -rf test"
run "script/rails generate rspec:install"
run "rm -rf autotest" # Others may use this, but I don't... so bye-bye!
# Cucumber
run "script/rails generate cucumber:install --rspec --capybara"
# Factory girl
run "mkdir spec/factories"
# JQuery setup
["controls","dragdrop","effects","prototype","rails"].each do |js|
remove_file "public/javascripts/#{js}.js"
end
get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.js"
get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
gsub_file 'config/application.rb', '# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)', 'config.action_view.javascript_expansions[:defaults] = %w(jquery rails)'
# Git init + add everything
remove_file ".gitignore"
file ".gitignore", <<-EOF
.DS_Store
.bundle
config/database.yml
db/*.sqlite3
log/*.log
tmp/**/*
EOF
git :init
git :add => "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment