Skip to content

Instantly share code, notes, and snippets.

View h-lame's full-sized avatar
💀
a momentary diversion on the road to the grave

Murray Steele h-lame

💀
a momentary diversion on the road to the grave
View GitHub Profile
Company A: $1,000 - $3,000
Company B: $6,000 - $10,000
Company C: $500 - $2,500
Feature: Allowing users to vote for an answer
As a visitor to the FAQ site
I want to be able to vote for the answer I think is best
In order to crowd-source the question having the most relevant answer
Scenario: I can vote for an answer
Given there is a question "What is jam?"
And it has been answered "Lovely sticky fruit stuff, best smeared on toast"
And it has been answered "A problem with too much traffic"
When I am on the page for question "What is jam?"
module PublishingLogic
module Migrations
class AddProgrammes < ActiveRecord::Migration
def self.up
create_table :programmes do |t|
t.boolean :publishing_enabled
t.datetime :published_at
t.datetime :published_until
t.timestamps
end
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'date'
#location = 'http://www.howdoesitfeel.co.uk/podcast.html'
location = './podcast.html'
module Capybara::Driver
class Envjs
PreTypingEvents = ['focus']
TypingEvents = ['keydown', 'keypress', 'keyup']
PostTypingEvents = ['change', 'blur']
def self.type_into(field, value)
PreTypingEvents.each { |e| field.trigger(e) }
field.set(value)
TypingEvents.each { |e| field.trigger(e) }
--
def stub_oauth!
TwitterAuth.stub!(:config).and_return({
'strategy' => 'oauth',
'oauth_consumer_key' => 'testkey',
'oauth_consumer_secret' => 'testsecret'
})
end
@h-lame
h-lame / gist:300181
Created February 10, 2010 09:35 — forked from sandro/gist:204016
# ARCHFLAGS may or may not matter - I set mine up this way just in case.
~$ echo $ARCHFLAGS
-arch i386 -arch x86_64
# Be sure to compile ruby with --enable-shared
~$ rvm install 1.9.1 --debug --reconfigure -C --enable-shared=yes
# Test to ensure that --enable-shared worked
~$ ruby -e "require 'rbconfig'; puts Config::CONFIG['ENABLE_SHARED']"
yes
# something like ...
# I think this goes in specs/support/whatever.rb
def it_should_be_invalid_without(*fields)
object_name = described_class.name.underscore
fields.each do |field|
it "should fail if #{field} is missing" do
instance_variable_get("@#{object_name}").send(:"#{field}=", nil)
instance_variable_get("@#{object_name}").should_not be_valid_for_create
@h-lame
h-lame / gist:279963
Created January 18, 2010 12:12 — forked from tomlea/gist:279962
class SomeController
before_filter :find_product
before_filter :sanitise_segment
def show
@product.reviews.for_segment(@segment).order_by(sort_order)
end
def show_extended_detail
# Assuming AR test models are present...
# The salient bits are:
#
# class Developer < ActiveRecord::Base
# has_many :audit_logs
# end
#
# class AuditLog < ActiveRecord::Base
# belongs_to :developer, :validate => true
# end