Skip to content

Instantly share code, notes, and snippets.

View acidlabs-snippets's full-sized avatar

acidlabs-snippets

View GitHub Profile
@acidlabs-snippets
acidlabs-snippets / rspec_devise.rb
Created December 3, 2012 18:52
Rspec Devise - Sign In User
# spec/spec_helper.rb
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# spec/support/devise.rb
RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
end
# spec/controllers/whatever/controller/that/needs/authentication.rb
before :each do
@acidlabs-snippets
acidlabs-snippets / rspec_database_cleaner.rb
Created December 3, 2012 19:32
Rspec Database Cleaner
# Gemfile
group :test do
gem "database_cleaner"
end
# spec/support/database_cleaner.rb
RSpec.configure do |config|
DatabaseCleaner.strategy = :truncation
config.before(:each) do
@acidlabs-snippets
acidlabs-snippets / acid-template.rb
Created January 13, 2013 04:58
Rails application template
# acid-template.rb
git :init
gitignore = run("curl https://gist.github.com/raw/3875160/5d2745ee9bcae0bb4addf4bc701d3fa9a48ce187/.gitignore")
file ".gitignore", gitignore
if yes?("Do you use RVM? (yes|no")
if yes?("Do you want to create a .rvmrc file for the project? (yes|no)")
# RVM
current_ruby = %x{rvm list}.match(/^=>\s+(.*)\s\[/)[1].strip
desired_ruby = ask("Which RVM Ruby would you like to use? [#{current_ruby}]")