Skip to content

Instantly share code, notes, and snippets.

@tomtt
Created March 29, 2009 19:27
Show Gist options
  • Save tomtt/87494 to your computer and use it in GitHub Desktop.
Save tomtt/87494 to your computer and use it in GitHub Desktop.
Rails template for all tools needed for a cucumbered app
# Ensure rails 2.3.1 is installed
# sudo gem install rails --source http://gems.rubyonrails.org
# The project_name is used to name the databases
project_name = ask("What is the project name?")
# Ignore files that should not be versioned
run "rm public/index.html"
file '.gitignore', <<-EOT
config/database.yml
*~
*.cache
*.log
.DS_Store
db/cstore/**
doc/api
doc/app
doc/plugins
coverage/*
vendor/gems/*/coverage
EOT
file 'tmp/.gitignore', <<-EOT
[^.]*
EOT
file 'log/.gitignore', <<-EOT
[^.]*
EOT
git :init
git :add => "."
git :commit => "-m 'Basic rails install'"
# Database config
file 'config/database.yml', <<"EOT";
<% PASSWORD_FILE = File.join(RAILS_ROOT, '..', '..', 'shared', 'config', 'dbpassword') %>
defaults : &defaults
adapter: mysql
encoding: utf8
host: localhost
username: root
password: <%= File.read(PASSWORD_FILE).chomp if File.readable? PASSWORD_FILE %>
development:
<<: *defaults
database: #{project_name}_development
test:
<<: *defaults
database: #{ project_name }_test
production:
<<: *defaults
database: #{ project_name }_production
EOT
rake("db:create:all")
rake("db:migrate")
git :add => "."
git :commit => "-m 'Database created'"
# Testing plugins
plugin 'rspec',
:git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails',
:git => 'git://github.com/dchelimsky/rspec-rails.git'
generate("rspec")
git :add => "."
git :commit => "-m 'Rspec plugins'"
# Factory girl and a factory definition for a User
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
file 'spec/factories.rb', <<'EOT';
# This file contains the factory definitions for factory_girl
require 'factory_girl'
Factory.define :user do |u|
u.sequence(:email) {|n| "test#{n}@example.com" }
u.password "letmein"
u.password_confirmation "letmein"
end
EOT
file 'spec/shared_helper.rb', <<'EOT';
# This file contains test helpers used by both rspec and cucumber
EOT
# spec_helper file, which requires the factories file and a file for
# test helper code
file 'spec/spec_helper.rb', <<-EOT
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec'
require 'spec/rails'
require File.expand_path(File.join(File.dirname(__FILE__), 'factories'))
require File.expand_path(File.join(File.dirname(__FILE__), 'shared_helper'))
Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
# lines, delete config/database.yml and disable :active_record
# in your config/boot.rb
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
config.include AuthenticatedTestHelper
end
EOT
git :add => "."
git :commit => "-m 'Factory girl and config'"
# Cucumber
plugin 'cucumber',
:git => 'git://github.com/aslakhellesoy/cucumber.git'
generate("cucumber")
git :add => "."
git :commit => "-m 'Cucumber'"
# resources_controller and friends
plugin 'resources_controller',
:git => 'git://github.com/ianwhite/resources_controller.git'
plugin 'response_for',
:git => 'git://github.com/ianwhite/response_for.git'
plugin 'response_for_rc',
:git => 'git://github.com/ianwhite/response_for_rc.git'
git :add => "."
git :commit => "-m 'Resources controller and friends'"
# Authlogic
gem 'authlogic'
git :add => "."
git :commit => "-m 'Auth logic'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment