Public Gists by patmaddox

Gravatar
Sun Nov 15 17:55:12 -0800 2009
1
2
3
    <h5 class="heading">Browse Our Cities</h5>
    <% territories = Territory.list.in_groups(3, false) %>
    <ul class="location_list">
Gravatar
Thu Nov 05 00:29:02 -0800 2009
1
2
3
# ~:$ irb
 :foo < :bar # => NoMethodError: undefined method `<' for :foo:Symbol
 
Gravatar
Wed Nov 04 15:54:19 -0800 2009
1
2
3
The assigns hash is used to access the ivars that the controller exposes to the view. You don't set
stuff in the assigns hash before making a request, because that would be the same as jamming an ivar
into the controller. Why do you need to do that? One common case I see is people wanting to set
Gravatar
Wed Nov 04 12:24:04 -0800 2009
1
2
3
# Typical way of handling the email in the controller
class UsersController < ApplicationController
  def create
Gravatar
Mon Sep 21 17:30:38 -0700 2009
1
2
3
class ObjectUnderTest
  def initialize(collab)
    @collaborator = collab
Gravatar
Mon Sep 21 16:41:52 -0700 2009
1
2
3
class ObjectUnderTest
  def initialize(collab)
    @collaborator = collab
Gravatar
Mon Sep 21 15:47:42 -0700 2009
1
2
3
class CheckoutClassBuilder
  def initialize
    @stubs = []
Gravatar
Wed Aug 19 11:12:01 -0700 2009
1
2
3
describe "sending an email" do
  it "should call the service" do
    service = mock('email service')
Gravatar
Tue Aug 18 10:21:20 -0700 2009
1
2
3
# USAGE:
#
# ruby task_runner.rb run -- start the daemon and stay on top
Gravatar
Fri Aug 14 14:42:05 -0700 2009
1
2
3
it "should create a new account" do
  lambda { do_post }.should change(Account, :count).by(1)
end
Gravatar
Tue Aug 11 16:42:14 -0700 2009
1
2
3
describe "authorize credit card gateway", :shared => true do
  describe "storing a credit card" do
    it "should set the authorize_net id" do
Gravatar
Thu Jul 09 14:21:32 -0700 2009
1
2
3
# done
# -- Matthew Peychich
Factory.define :venue do |v|
Gravatar
Thu Jul 09 14:04:06 -0700 2009
1
2
3
class Address < ActiveRecord::Base
  after_save :ensure_matching_postal_code
 
Gravatar
Tue Jul 07 13:41:36 -0700 2009
1
2
3
loop do
  ActiveRecord::Base.connection.execute "DELETE FROM sessions WHERE updated_at < '#{7.days.ago.to_s(:db)}' LIMIT 1000"
  sleep 2
Gravatar
Fri Jul 03 15:51:49 -0700 2009
1
2
3
def funky_foo(shakalaka, &block)
  if some_condition
    # lines of code
Gravatar
Sun Jun 28 21:01:33 -0700 2009
1
2
3
require 'timeout'
 
seconds_to_run = 2
Gravatar
Fri Jun 05 00:56:01 -0700 2009
1
2
3
class RestfulReader
  def get(things)
    # GET funky restafarian
Gravatar
Mon Jun 01 11:55:46 -0700 2009
1
2
3
describe Agency do
  before(:each) do
    puts "in before(:each)"
Gravatar
Wed May 27 19:56:50 -0700 2009
1
2
3
# This comes from GenericWebLibrary
class BaseComponent
end
Gravatar
Mon May 18 18:10:05 -0700 2009
1
2
3
class SimpleAR
  def self.has_many(collection)
    define_method(collection) do