Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
require 'spec_helper.rb'
describe "Migration" do
before(:all) do
MyModel = Object.new
require 'my_migration'
end
before(:each) do
Spec::Matchers.create(:be_successful) do
matches do |rack|
rack.status == 200
end
message do |not_string, rack|
"Expected #{describe_request(rack)}#{not_string} " \
"to be successful, but it returned a #{rack.status}"
end
end
<p><b>Title:</b> <%=h @race.title %></p>
<p><b>State:</b> <%=h @race.state.title %></p>
<p><b>Racetype:</b> <%=h @race.racetype.title %></p>
<hr>
<h3>Questions</h3>
<% form_tag :action => :manage_questions, :id => @race do %>
<table>
@dchelimsky
dchelimsky / an example
Created September 30, 2008 14:01 — forked from zdennis/an example
require File.dirname(__FILE__) + '/../spec_helper'
class Foo
def self.per_page
10
end
end
describe Foo do
should_have_per_page 10
given "logged in" do
login
end
given "anonymous" do end
describe "Homepage: url(:home)", :given => "logged in" do
before(:each) do
@rack = request(:home)
end
Feature: Compile C code into Ruby extensions.
In order to automate compilation process.
As a Gem developer.
I want rake tasks compile source code for me.
Scenario: Compile single extension
Given a safe project directory
And scaffold code for extension 'extension_one'
And 'tmp' folder is deleted
@dchelimsky
dchelimsky / gist:24369
Created November 13, 2008 05:04 — forked from dkubb/gist:5524
resource 'posts/:id' do |id|
get do
# show post id
end
delete do
# destroy post id
end
get :comments do
describe 'A Collection' do
subject { Collection.new }
action { clear }
should_return_self
should_clear_itself
end
module Matchers
class HaveNotice
def initialize(contents, scope)
@contents, @scope = contents, scope
end
def matches?(response)
response.should @scope.have_tag('div.notice', @contents)
end
class Cart < ActiveRecord::Base
has_many :items, :class_name => 'CartItem', :dependent => :destroy
# ...
def empty!
items.each(&:destroy)
self
end