Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.
This file contains 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 "test/unit" | |
class Module | |
alias_method :old_private, :private | |
def private(*args) | |
old_private(*args) | |
end | |
end |
This file contains 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 "set" | |
module RakeTask | |
CALLED = Set.new | |
NAMESPACES = [] | |
TASKS = Hash.new { |h, k| h[k] = Struct.new(:blocks, :deps).new([], []) } | |
def self.call(name) | |
return if CALLED.include?(name) | |
raise "Unknown task: #{name.inspect}" unless TASKS.key?(name) |
This file contains 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 "test/unit" | |
module Kernel | |
def describe(description, &block) | |
Class.new(Unitard::TestCase, &block) | |
end | |
end | |
module Unitard | |
class TestCase < Test::Unit::TestCase |
This file contains 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 "rubygems" | |
require "johnson" | |
require "./visitor.rb" | |
js =<<-END | |
function top() { | |
"top docstring", { command: true } | |
doSomething(); | |
}; |
This file contains 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
class Array | |
def poke(item, &block) | |
push(item) | |
yield(item) | |
pop | |
end | |
end |
This file contains 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
namespace :db do | |
task :migrate => :clear_load_paths do | |
Dependencies.load_paths = @old_load_paths | |
end | |
task :clear_load_paths do | |
@old_load_paths = Dependencies.load_paths | |
Dependencies.load_paths = [] | |
end | |
end |
This file contains 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
jbarnette@slice:/etc$ dpkg -l 'libxslt*' | |
Desired=Unknown/Install/Remove/Purge/Hold | |
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend | |
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) | |
||/ Name Version Description | |
+++-==============-==============-============================================ | |
un libxslt-dev <none> (no description available) | |
un libxslt0-dev <none> (no description available) | |
un libxslt1 <none> (no description available) | |
ii libxslt1-dev 1.1.22-1ubuntu XSLT processing library - development kit |
This file contains 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
class ApplicationController < ActionController::Base | |
include Intercession | |
before_filter :load_skin | |
before_filter :require_user | |
before_filter :require_matching_skin | |
before_filter :require_admin | |
def load_skin | |
session.skin = Skin.for_request(request) |
This file contains 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
on "#list" do | |
map :bgcolor => :color | |
@members.each_with_index do |m, i| | |
element(:bgcolor => i % 2 == 0 ? '#FFCCCC' : '#CCCCFF') | |
end | |
end | |
on("#name").tag.content = @member.name | |
OlderNewer