Skip to content

Instantly share code, notes, and snippets.

View jherdman's full-sized avatar

James Herdman jherdman

View GitHub Profile
testy test test
Feature: Pricing
In order to purchase two items from the store
As a Store user
I should be able to add two items and checkout with the right price displayed
Scenario: Successful checkout
Given the user adds the "Unique Ability" product to the cart
And then adds "Strategy Circle Software" product to the cart
When the user views the cart, it should have 2 items totalling "$130"
Then the user logs in and confirms the right price
@jherdman
jherdman / argh.js
Created December 12, 2010 22:22
My pains with objects in JavaScript
// Suppose we have a useful collection of methods for objects...
var Book = {
publish : function (publisherUrl) {
// do stuff...
}
, update : function ()
// do more stuff
}
#!/usr/bin/env bash
# The following is cribbed directly from the rvm-site project. Please see
# https://github.com/wayneeseguin/rvm-site
ruby_name="ruby-1.9.2-p136"
gemset_name="my_project_name"
environment_id="$ruby_name@$gemset_name"
#
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:402: warning: already initialized constant EMPTY_TASK_ARGS
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:450: warning: already initialized constant EMPTY
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:958: warning: already initialized constant RUBY_EXT
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:962: warning: already initialized constant RUBY
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:1031: warning: already initialized constant LN_SUPPORTED
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:1240: warning: already initialized constant ARRAY_METHODS
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rake.rb:1243: warning: already initialized constant MUST_DEFINE
/Users/james/.rvm/rubies/ruby-1.9.2-p180/lib/
@jherdman
jherdman / attempt.rb
Created June 6, 2011 14:03
Attempting to find an attribute on an object
module Attempt
def attempt(*method_names)
responding_method = method_names.detect { |method| respond_to?(method) }
send(responding_method) or raise NoMethodError
end
end
class Object
include Attempt
end
[2011-06-08 11:20:53] /Users/james/.rvm/wrappers/ruby-1.8.7-p334/ruby ./configure --prefix=/Users/james/.rvm/rubies/rbx-2.0.0pre --enable-version=1.8,1.9 -C --enable-version=1.8,1.9
Usage: configure [options]
Configure settings
--log-file NAME Write log to file NAME
--rake NAME Use NAME as 'rake' during build
--tar NAME Use NAME as 'tar'
--perl NAME Use NAME as 'perl' during build
Language version settings
let(:my_model) { Factory.stub(:my_model) }
let(:collection) { [....] }
before do
my_model.stub(:my_db_method) { collection }
end
it 'does stuff to illustrate a point' do
my_model.should_receive(:my_db_method) { collection }
# Don't do this
[].tap do |my_array|
collection.each do |item|
# process...
my_array << item
end
end
# Don't do this
collection.each_with_object([]) do |item, my_array|
# Given...
function farp {
find $1 -type f -exec sed -i $2 {} \;
}
> farp spec 's/foo/bar/'
find: -exec: no terminating ";" or "+"
# How do I prevent this error?