This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def should_be_a_subset(superset, records_selected_by_scope, &condition) | |
flunk "Your superset is empty" if superset.empty? | |
flunk "Your scope did not select any records" if records_selected_by_scope.empty? | |
records_selected_by_block, records_excluded_by_block = superset.partition(&condition) | |
flunk "Your test condition did not select any records" if records_selected_by_block.empty? | |
flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty? | |
records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: spec payment.rb | |
# Depends on Ruby and Rspec. | |
# | |
# Modify this code to compute the correct fee amount for a given payment amount. | |
# Add additional tests to cover any behavior you introduce. | |
class Payment | |
BASIS_POINTS = 290 | |
INTERCHANGE = 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'strscan' | |
require 'set' | |
class SqlQuery < Struct.new(:table, :where, :order) | |
def to_json | |
[table, where, order].to_json | |
end | |
end | |
class SqlScanner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'www/mechanize' | |
# Patches WWW::Mechanize for Cucumber + Webrat | |
module WWW | |
class Mechanize | |
def self.log_disabled | |
@@log ||= Logger.new(STDOUT) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Template which configures a generic Rails app with Shoulda, Factory Girl, | |
# HAML, etc while commiting each step into git. | |
# | |
# Make sure you have Rails 2.3rc1 or greater installed and run: | |
# rails -d mysql -m http://gist.github.com/57458 | |
# Helper methods | |
# Modified version of the "gem" method which places the "config.gem..." lines | |
# after the examples in config/environment.rb. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for dir in `find . -empty -type d -maxdepth $1`; do | |
if [ not `ls -A $dir` ]; then | |
echo "$dir" | |
fi | |
done | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Come taste some fine forties, cheetos, and various stank and non-stank bitches | |
on the sickest corner in SoMA! We're starting early so you can drop by | |
before heading to your midnight destinations. | |
Time | |
~7pm | |
Location | |
Jessie at 6th St, in front of the chain link fence | |
NewerOlder