Skip to content

Instantly share code, notes, and snippets.

@voldy
voldy / authentication.feature
Created December 26, 2011 17:42 — forked from ehosick/authentication.feature
Devise Behavior Driven Development (BDD) Features using cucumber, pickle, machinist
# Note: This does not yet align 100% with out of the box devise. I will work on that.
Feature: Authentication
In order to protect my assets stored within a system
As any user
I would like to be verified as the rightful owner of those assets through authentication
Scenario: No authenticated user within the system
Given a user exists with email: "someuser@someuser.com"
And I am not authenticated
@voldy
voldy / Capfile
Created November 17, 2011 19:24 — forked from smaboshe/Capfile
Rails 3.1.x application Capistrano deployment recipe
load "deploy" if respond_to?(:namespace) # cap2 differentiator
DEPLOYMENT_CONFIG = YAML.load_file("./config/config.yml")["production"]
# Ref: https://github.com/capistrano/capistrano/issues/81#issuecomment-1994285
require "bundler/capistrano"
# Uncomment if you are using Rails' asset pipeline
load "deploy/assets"
@voldy
voldy / deploy.rb
Created March 3, 2011 23:53 — forked from kpumuk/deploy.rb
namespace :deploy do
desc 'Bundle and minify the JS and CSS files'
task :precache_assets, :roles => :app do
root_path = File.expand_path(File.dirname(__FILE__) + '/..')
jammit_path = Dir["#{root_path}/vendor/gems/jammit-*/bin/jammit"].first
yui_lib_path = Dir["#{root_path}/vendor/gems/yui-compressor-*/lib"].first
assets_path = "#{root_path}/public/assets"
# Precaching assets
run_locally "ruby -I#{yui_lib_path} #{jammit_path}"
@voldy
voldy / mass_assigment.rb
Created December 18, 2010 21:21
Allow mass assignment RSpec matcher tested with Mongoid
# allow_mass_assignment_of matcher
# Extracted from Shoulda
# Works with Mongoid
module RSpec
module Matchers
# Ensures that the attribute can be set on mass update.
#
# it { should_not allow_mass_assignment_of(:password) }
@voldy
voldy / cancan_mongoid.rb
Created December 17, 2010 16:35 — forked from bowsersenior/cancan_mongoid.rb
How to get CanCan to work with Mongoid 2
module CanCan
class Query
def sanitize_sql(conditions)
conditions
end
end
# customize to handle Mongoid queries in ability definitions conditions
class CanDefinition
def matches_conditions_hash?(subject, conditions = @conditions)
@voldy
voldy / cookie_steps.rb
Created November 28, 2010 20:39 — forked from nruth/cookie_steps.rb
Testing login "remember me" feature with Capybara 1.0.0 (rack::test or selenium) - deleting the session cookie (only)
@voldy
voldy / rspec-syntax-cheat-sheet.rb
Created November 27, 2010 16:03 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2.0 syntax Cheet Sheet
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
# Application Generator Template
# Devise, Cucumber, RSpec... for use with Rails 3
# http://gist.github.com/513564
# Based on the Mongoid/Devise template: http://github.com/fortuity/rails3-mongoid-devise/raw/master/template.rb
#
#
# Installs my js_lib rakefile, found: http://gist.github.com/raw/628715/js_lib.rake
# (to keep js libraries out of source control.)
#
# Usage:
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
@voldy
voldy / rakefile.rb
Created September 26, 2010 18:16
Sprockets Watch
#!/usr/bin/env ruby
#
# sprockets watch
# ------------------------------------------------------
# inspired by Compass from Chris Eppstein
# minify and concat code from Mark Story
# put together by Kjell Bublitz
# using Sprockets!
#
# sources: