Skip to content

Instantly share code, notes, and snippets.

module SpecHelper
def session_data
cookies = @response.headers["Set-Cookie"]
serialised = Rack::Utils::parse_query(cookies)["rack.session"]
Marshal.load(serialised.unpack('m*').first)
end
end
poncho (sinatra-09)% ruby spec/sitemap_spec.rb -e 'should have a urlset tag'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31: warning: The :env option is deprecated; use :environment instead.
F
1)
ArgumentError in 'sitemap XML should have a urlset tag'
tried to create Proc object without a block
/Library/Ruby/Gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:589:in `define_method'
/Library/Ruby/Gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:589:in `route'
/Library/Ruby/Gems/1.8/gems/sinatra-0.9.0.2/lib/sinatra/base.rb:569:in `get'
# This isn't as elegant as some of the other solutions for running multiple versions
# of Ruby but it's simple, straight-forward and has worked well for me so far. I'm
# currently running the most recent stable versions of 1.8.5, 1.8.6, 1.8.7, and
# 1.9.1 and plan to experiment with some patched versions as well.
# pull one of the tarballs down and extract:
$ cd /tmp
$ curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz |
tar xvzf -
$ cd ruby-1.9.1-p0
class Show < ActiveRecord::Base
has_many :episodes
has_many :users, :through => :episodes
end
class User < ActiveRecord::Base
has_many :episodes
has_many :shows, :through => :episodes
end
module RequireBodyCopyMacros
def should_require_body_copy
context "create" do
should_display_error_if_body_not_set :post_create
end
context "update" do
should_display_error_if_body_not_set :put_update
end
@gma
gma / gist:234446
Created November 14, 2009 08:43 — forked from jc00ke/gist:234265
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module UserSpecHelper
def valid_user_attributes
{ :username => 'jc00ke',
:email => 'jc00ke@example.com',
:password => 'p@ssw0rd' }
end
def invalid_usernames
module ActionController
module Assertions
module SelectorAssertions
protected
def response_from_page_or_rjs
HTML::Document.new(body, strict = false, xml = false).root
end
end
end
end
#!/bin/sh
# Copy this script to hooks/post-receive in your main git repository
# in order to prompt integrity to build the latest version of your project
# when changes are pushed. Don't forget to make it executable with chmod +x.
HOSTNAME="your.integrity.server"
# Set the username and password if your server is protected with basic auth
#
# I'm rather pleased with this use of Python decorators for applying
# stubs to a class before a test method.
#
# It feels a bit like a poor man's shoulda. :-)
import os
import unittest2 as unittest
import satisfaction
server {
listen 80;
server_name effectif.com;
root /var/apps/nesta/current/public;
passenger_enabled on;
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
}