Skip to content

Instantly share code, notes, and snippets.

View alanmaciel's full-sized avatar
Work and play, same thing, differing conditions. ~Mark Twain

Alan Maciel alanmaciel

Work and play, same thing, differing conditions. ~Mark Twain
View GitHub Profile
@alanmaciel
alanmaciel / gist:3989408
Created October 31, 2012 19:54
.gitignore
# bundler state
/.bundle
/vendor/bundle/
/vendor/ruby/
# minimal Rails specific artifacts
db/*.sqlite3
/log/*
/tmp/*
@alanmaciel
alanmaciel / gist:3989428
Created October 31, 2012 20:00
database.yml
development:
host: localhost
adapter: postgresql
encoding: unicode
database: sample_app_development
test: &test
host: localhost
adapter: postgresql
encoding: unicode
@alanmaciel
alanmaciel / gist:3989435
Created October 31, 2012 20:02
Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' 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(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
@alanmaciel
alanmaciel / gist:3989507
Created October 31, 2012 20:10
rake db operations
rake db:migrate
rake db:rollback
rake db:migrate VERSION=0
@alanmaciel
alanmaciel / gist:3989511
Created October 31, 2012 20:11
Routes file
Shoppertown::Application.routes.draw do
match '/benefits', to: 'content_pages#benefits'
match '/howto_buy', to: 'content_pages#howto_buy'
match '/howto_sell', to: 'content_pages#howto_sell'
match '/about', to: 'content_pages#about'
match '/contact', to: 'content_pages#contact'
match '/policies', to: 'content_pages#policies'
match '/legal', to: 'content_pages#legal'
authenticated :user do
@alanmaciel
alanmaciel / gist:3989517
Created October 31, 2012 20:11
Generate integration test
rails generate integration_test content_pages
@alanmaciel
alanmaciel / gist:3989523
Created October 31, 2012 20:13
spec/requests/content_pages_spec.rb
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
@alanmaciel
alanmaciel / gist:3989953
Created October 31, 2012 21:23
Test gems on Macintosh OS X
group :test do
gem 'capybara', '1.1.2'
gem 'rb-fsevent', '0.9.1', :require => false
gem 'growl', '1.0.3'
end
(OS X users may have to install Growl and growlnotify as well)
@alanmaciel
alanmaciel / gist:3989960
Created October 31, 2012 21:24
Additions to the default Guardfile.
require 'active_support/core_ext'
# Ensures that Guard doesn’t run all the tests after a failing test passes
# (to speed up the Red- Green-Refactor cycle):
guard 'rspec', :version => 2, :all_after_pass => false do
.
.
.
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
@alanmaciel
alanmaciel / gist:3990030
Created October 31, 2012 21:31
Speed test with Spork spec/spec_helper.rb
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)