This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://gist.github.com/10524 | |
# Prevents autotest from running your entire test suite after fixing a failed test. | |
# Works with ZenTest 3.10.0 | |
# Place this in your .autotest file: | |
require 'rubygems' | |
require 'active_support' | |
class Autotest | |
def run_with_not_rerunning_everything | |
hook :initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'benchmark' | |
class Test::Unit::TestCase | |
alias_method :real_run, :run unless instance_methods.include?("real_run") | |
@@total = {} | |
def run(result) | |
if block_given? | |
test = ::Benchmark.measure { real_run(result) { yield } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'wirble' | |
require 'pp' | |
Wirble.init | |
Wirble.colorize | |
class Object | |
def local_methods | |
(methods - Object.instance_methods).sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dan Pickett, http://en.oreilly.com/rails2009/profile/46469 | |
Brian Cardarella, http://en.oreilly.com/rails2009/profile/45790 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "My Custom Query" do | |
setup do | |
@positive_record = positive_record_getter | |
@negative_record = negative_record_getter | |
@result_set = Report.custom_query | |
end | |
should "have a result set that contains the positive record" do | |
assert_contains @result_set, @positive_record | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
:UY: Uruguay | |
:NP: Nepal | |
:BS: Bahamas | |
:HT: Haiti | |
:LK: Sri Lanka | |
:SE: Sweden | |
:DZ: Algeria | |
:TW: Taiwan | |
:GU: Guam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:HI: Hawaii | |
:KY: Kentucky | |
:MN: Minnesota | |
:OK: Oklahoma | |
:FM: Federated States Of Micronesia | |
:MT: Montana | |
:NJ: New Jersey | |
:PW: Palau | |
:SD: South Dakota | |
:VI: Virgin Islands |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Float | |
# Takes a fraction and will round a float to the nearest multiple | |
# >> k = 0.4 | |
# >> k.round_to_fraction | |
# => 0.5 | |
# >> k = 0.75 | |
# >> k.round_to_fraction | |
# => 1.0 | |
# >> k.round_to_fraction(0.65) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Shoulda # :nodoc: | |
module ActiveRecord # :nodoc: | |
# Examples: | |
# class Book < ActiveRecord::Base | |
# named_scope :test, :conditions => { :name => "test" } | |
# named_scope :by_name, lambda { |n| { :conditions => { :name => n} } } | |
# end | |
# | |
# RSpec: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HaveFilter matchers for RSpec | |
# save as: spec/support/have_filter.rb | |
# | |
# class HomeController < ApplicationController | |
# before_filter :require_user, :except => [:action_1, :action_2] | |
# ... | |
# end | |
# | |
# describe HomeController do | |
# it { should have_before_filter(:require_user).except(:action_1, :action_2) } |