Skip to content

Instantly share code, notes, and snippets.

View Gemfile
source 'https://rubygems.org'
gem 'minitest'
gem 'webmock'
@floehopper
floehopper / atom.rb
Last active Jan 4, 2016 — forked from chrislo/gist:8543385
Evaluator for Little Schemer chapter 1
View atom.rb
class Atom
attr_reader :symbol
def initialize(symbol)
@symbol = symbol
end
def ==(other)
self.symbol == other.symbol
end
View test.rb
require 'test/unit'
require 'rubygems'
require 'mocha'
class Foo
def self.say_hello_to(name)
Bar.hello(name)
end
end
View raisable_redirections.rb
module RaisableRedirections
def self.included(other)
other.send(:around_filter, :handle_raisable_redirections)
end
protected
def raise_redirect_to(*args)
raise Redirect.new(*args)
end
@floehopper
floehopper / gist:214172
Created Oct 20, 2009 — forked from technoweenie/gist:213780
how do you test algorithms?
View gist:214172
# how do you test algorithms?
class Pythagoream < Struct.new(:a, :b)
def result
a**2 + b**2
end
end
# I prefer to "invert" the algorithm somehow
# or calculate the expected result another way.