Skip to content

Instantly share code, notes, and snippets.

@arikfr
Created July 8, 2011 08:50
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 arikfr/1071387 to your computer and use it in GitHub Desktop.
Save arikfr/1071387 to your computer and use it in GitHub Desktop.
My Rails projects template
# create rvmrc file
create_file ".rvmrc", "rvm use 1.9.2-patched@#{app_name}"
run "rvm gemset create #{app_name}"
run "rvm use 1.9.2-patched@#{app_name}"
gem "compass"
gem 'compass-less-plugin'
gem 'barista'
gem "jquery-rails"
# rspec, factory girl, webrat, autotest for testing
gem 'database_cleaner', :group => :test
gem 'rspec-rails', :group => [:test, :development]
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'faker', :group => :test
gem 'spork', :group => :test
gem 'guard-spork', :group => :test
gem 'guard-rspec', :group => :test
gem 'rb-fsevent', :group => :test
gem 'growl', :group => :test # also install growlnotify from the Extras/growlnotify/growlnotify.pkg in Growl disk image
run 'bundle install'
rake "db:create", :env => 'development'
rake "db:create", :env => 'test'
remove_file 'public/javascripts/rails.js' # jquery-rails replaces this
generate 'jquery:install --ui'
generate 'rspec:install'
remove_file 'spec/spec_helper.rb'
create_file 'spec/spec_helper.rb' do
<<-eos
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = true
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
# This code will be run each time you run your specs.
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
# reload Factories:
Factory.definition_file_paths = [
File.join(Rails.root, 'spec', 'factories')
]
Factory.find_definitions
# reload routes:
#{app_name.capitalize}::Application.reload_routes!
end
eos
end
inject_into_file 'app/views/layouts/application.html.erb', :after => "<%= stylesheet_link_tag :all %>" do
"\n<%= stylesheet_link_tag 'less.css' %>"
end
inject_into_file 'config/application.rb', :after => "config.filter_parameters += [:password]" do
<<-eos
# Customize generators
config.generators do |g|
g.stylesheets false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
eos
end
run "echo '--colour --drb --format doc' >> .rspec"
run 'guard init spork'
run 'guard init rspec'
run 'compass init rails -r less . --using less'
generate 'barista:install'
empty_directory 'app/coffeescript'
# clean up rails defaults
remove_file 'public/index.html'
remove_file 'rm public/images/rails.png'
run 'cp config/database.yml config/database.example'
run "echo 'config/database.yml' >> .gitignore"
# commit to git
git :init
git :add => "."
git :commit => "-a -m 'create initial application'"
say <<-eos
============================================================================
Your new Rails application is ready to go.
Don't forget to scroll up for important messages from installed generators.
eos
@arikfr
Copy link
Author

arikfr commented Jul 8, 2011

Installs RSpec, Spork, Factory Girl, Faker, Guard, Compass with Less Framework, Barista

Based on this blog post: http://everydayrails.com/2011/02/28/rails-3-application-templates.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment