Skip to content

Instantly share code, notes, and snippets.

@mrkplt
Created May 17, 2012 00:39
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 mrkplt/2715219 to your computer and use it in GitHub Desktop.
Save mrkplt/2715219 to your computer and use it in GitHub Desktop.
Rails App init with test framework
$ rails new <app_name> --skip-test-unit
$ cd <app_name>/
$ git init
$ git add .
$ git commit -m 'first commit'
$ git remote add origin <git repo>
$ git push -u origin master
$ mate .
/**
* Alter Gemfile
**/
########################################################################
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'sqlite3'
gem 'haml-rails'
gem 'jquery-rails'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem "rspec-rails", :group => [:test, :development]
group :development do
gem 'wirble'
gem 'hirb'
end
group :test do
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'launchy'
gem 'database_cleaner'
gem 'cucumber-rails', :require => false
gem "spork"
gem "guard-spork"
gem 'guard-cucumber'
gem 'shoulda-matchers'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
########################################################################
$ bundle install
$ rails g rspec:install
$ guard init rspec
$ gem install rb-fsevent
$ spork --bootstrap
$ guard init spork
$ rails generate cucumber:install --spork
/**
* Alter spec/spec_helper.rb
**/
########################################################################
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
# 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}
RSpec.configure do |config|
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.include FactoryGirl::Syntax::Methods
end
end
Spork.each_run do
FactoryGirl.reload
end
########################################################################
/**
* Alter Guardfile
**/
########################################################################
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('spec/spec_helper.rb')
watch(%r{^spec/support/.+\.rb$})
end
guard 'rspec', :version => 2, :cli => "--drb --color --fail-fast --format nested", :all_on_start => false, :all_after_pass => false do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/.+_spec\.rb})
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
guard 'cucumber' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
########################################################################
$ touch spec/factories.rb
/**
* spec/factories.rb
**/
########################################################################
FactoryGirl.define do
end
########################################################################
/**
* ~/.irbrc
**/
########################################################################
require 'rubygems' rescue nil
%x{gem install 'wirble' --no-ri --no-rdoc} unless Gem.available?('wirble')
Gem.refresh
require 'wirble'
require 'hirb'
# load wirble
Wirble.init
Wirble.colorize
colors = Wirble::Colorize.colors.merge({
:object_class => :purple,
:symbol => :purple,
:symbol_prefix => :purple
})
Wirble::Colorize.colors = colors
# load hirb
Hirb::View.enable
########################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment