View Gemfile
source 'https://rubygems.org' | |
gem 'minitest' | |
gem 'webmock' |
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 |
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. |