Skip to content

Instantly share code, notes, and snippets.

@knwang
knwang / Config.ru
Created June 2, 2011 07:08
Rack config for faye-snake
require 'faye'
require File.dirname(__FILE__) + '/main'
Sinatra::Base.set(:run, false)
Sinatra::Base.set(:env, ENV['RACK_ENV'])
use Faye::RackAdapter, :mount => '/faye', :timeout => 45
run Sinatra::Application
@knwang
knwang / user_views_candidates.feature
Created October 5, 2011 00:15
Proofing_oven: User views candidates feature
@http://www.pivotaltracker.com/story/show/18733537 @candidates
Feature: User views candidates
In order to hire amazing people
As a signed in user
I want to see a list of candidates
- Candidates page displays all candidates
- Sorted by last name, first name
- Fields displayed include:
-- Name (last, first)
@knwang
knwang / candidate_fabricator.rb
Created October 5, 2011 00:18
Proofing_oven: Candidate Fabricator
Fabricator(:candidate) do
first_name "John"
last_name "Doe"
phone "555-222-3333"
email "johndoe@example.com"
github "moo"
twitter "chirp"
local true
willing_to_relocate false
added_on "2009-01-22"
@knwang
knwang / create_candidate.rb
Created October 5, 2011 00:19
Proofing_oven: Create Candidate Migration
class CreateCandidates < ActiveRecord::Migration
def self.up
create_table :candidates do |t|
t.string :first_name
t.string :last_name
t.string :phone
t.string :email
t.string :github
t.string :twitter
t.boolean :local
@knwang
knwang / paths.rb
Created October 5, 2011 00:21
Proofing_oven: feature support paths
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case page_name
@knwang
knwang / routes.rb
Created October 5, 2011 00:22
Proofing_oven: routes
ProofingOven::Application.routes.draw do
match 'ui(/:action)', controller: 'ui'
root to: 'ui#index'
resources :candidates, only: [:index]
end
@knwang
knwang / candidates_controller.rb
Created October 5, 2011 00:23
Proofing_oven: Candidates Controller
class CandidatesController < ApplicationController
expose(:candidates) { Candidate.all }
end
@knwang
knwang / index.html.haml
Created October 5, 2011 00:33
Proofing_oven: Candidates list view
%table.standard
%thead
%tr
- ["Name", "Phone", "Email", "Github", "Twitter", "Local", "Willing to Relocate"].each do |th|
%th= th
%tbody
- candidates.each do |candidate|
%tr
%td= candidate.full_name
%td= candidate.phone
@knwang
knwang / candidate_spec.rb
Created October 5, 2011 00:35
Proofing_oven: Candidate Spec
require 'spec_helper'
describe Candidate do
subject { Fabricate(:candidate, first_name: "Joe", last_name: "Doe") }
describe "#full_name" do
its(:full_name) { should == "Joe Doe" }
end
end
@knwang
knwang / candidate.rb
Created October 5, 2011 00:35
Proofing_oven: Candidate Model
class Candidate < ActiveRecord::Base
def full_name
[first_name, last_name].join(' ')
end
end