Skip to content

Instantly share code, notes, and snippets.

View adam-e-trepanier's full-sized avatar

Adam Trepanier adam-e-trepanier

View GitHub Profile
@adam-e-trepanier
adam-e-trepanier / feature-scenario
Created September 27, 2013 03:44
rspec feature
require 'spec_helper'
feature "Credential idempotency" do
# He shouldn't be describing it anyway, but you
# could write the nice little stuff here
scenario "Editing authorization information of a credential increments the version" do
prev_version = obj.credential_version
obj.modify_encrypted_data # A real Domain model or moved to a page object
@adam-e-trepanier
adam-e-trepanier / spec_helper.rb
Created December 15, 2011 20:30
json helper in spec_helper
def set_json_headers
request.env['HTTP_ACCEPT'] = 'application/json, text/javascript, *'
request.env['CONTENT_TYPE'] = 'application/json'
end
# controller code for /foo/1
before_filter do |controller|
controller.some_verification(params[:id])
end
# controller code for /foo/1/bar/1
before_filter do |controller|
controller.some_verification(params[:foo_id])
@adam-e-trepanier
adam-e-trepanier / singleton_class.rb
Created July 15, 2011 03:18
Singleton (eigen) class
module Kernel
# Returns the object's singleton class.
def singleton_class
class << self
self
end
end unless respond_to?(:singleton_class) # exists in 1.9.2
# class_eval on an object acts like singleton_class.class_eval.
def class_eval(*args, &block)
@adam-e-trepanier
adam-e-trepanier / spec_helper.rb
Created July 14, 2011 19:00
Spork reload factories
Spork.each_run do
# This code will be run each time you run your specs.
AppName::Application.reload_routes!
Factory.factories.clear
Dir.glob("#{::Rails.root}/spec/factories/*.rb").each { |file| load "#{file}" }
end
@adam-e-trepanier
adam-e-trepanier / gist:1075840
Created July 11, 2011 13:30
JSON strings (for now)
{\"beverage\":
{
\"approved\":null,
\"created_at\":\"2011-07-11T13:24:08Z\",
\"description\":\"The king of beers\",
\"id\":1,
\"name\":\"Bud Light\",
\"producer\":\"Anheuser-Busch\",
\"updated_at\":\"2011-07-11T13:24:08Z\"
}
@adam-e-trepanier
adam-e-trepanier / gist:1070149
Created July 7, 2011 18:16
add warden failure app
We couldn’t find that file to show.
@adam-e-trepanier
adam-e-trepanier / gist:1070146
Created July 7, 2011 18:14
add warden failure app
We couldn’t find that file to show.
@adam-e-trepanier
adam-e-trepanier / gist:1070145
Created July 7, 2011 18:14
add warden failure app
We couldn’t find that file to show.
@adam-e-trepanier
adam-e-trepanier / gist:1070144
Created July 7, 2011 18:14
add warden failure app
We couldn’t find that file to show.