Skip to content

Instantly share code, notes, and snippets.

## reversesortby.rb
class ReverseSortBy
include Comparable
attr_reader :value
def initialize(value)
@value = value
end
def <=>(other)
module Kernel
def irb_drop(context=nil, *argv)
require 'irb'
require 'pp'
require 'yaml'
original_argv = ARGV.dup
ARGV.replace(argv) # IRB is being stupid
IRB.setup(nil) # FIXME: must only be called once
irb = IRB::Irb.new(IRB::WorkSpace.new(context))
IRB.conf[:IRB_RC].call(irb.context) if IRB.conf[:IRB_RC] # loads the irbrc?
module Cucumber
module Rake
class Task
class BundledCucumberRunner #:nodoc:
attr_reader :args
def initialize(executable, cucumber_opts, feature_files)
@args = (
[`which bundle`.chomp, 'exec', executable]+
cucumber_opts +
require 'set'
# Create and manage forks.
# Provides a basic facility to communicate between the forks and the parent
#
# Example:
# pool = ForkPool.new
# child = pool.fork do |parent|
/*
Usage:
if (CssDetector.supports('box-shadow')) {
// load 'standard-box-shadows.css'
} else if (CssDetector.supports('-moz-box-shadow')) {
// load 'mozilla-box-shadows.css'
} else if (CssDetector.supports('-webkit-box-shadow')) {
// load 'webkit-box-shadows.css'
} else {
// load 'fake-box-shadows.css'
BareTest.suite "Integer Division" do
data :integer_division, :csv, <<-DATA
@divident, @divisor, @expected_quotient
1, 1, 1
1, 2, 0
2, 2, 1
DATA
setup data(:integer_division)
Integer Division
[ success ] 1 divided by 1 returns an integer
[ success ] 1 divided by 2 returns an integer
[ success ] 2 divided by 2 returns an integer
[ success ] 1 divided by 1 equals 1
[ success ] 1 divided by 2 equals 0
[ success ] 2 divided by 2 equals 1
BareTest.suite "Integer Division" do
setup :addition do
@divident, @divisor, @expected_quotient = 1, 1, 1
end
setup :addition do
@divident, @divisor, @expected_quotient = 1, 2, 0
end
setup :addition do
@divident, @divisor, @expected_quotient = 2, 2, 1
end
@apeiros
apeiros / fork.rb
Created March 25, 2010 19:34
An object representing a fork, containing data about it like pid, name, # exit_status, exception etc.
# An object representing a fork, containing data about it like pid, name,
# exit_status, exception etc.
# It also provides facilities for parent and child process to communicate
# with each other.
class Fork
# Exceptions that have to be ignored in the child's handling of exceptions
IgnoreExceptions = [::SystemExit]
# Raised when a fork raises an exception that can't be dumped
# This is the case if the exception is either an anonymous class or
BareTest.suite do
suite "Success" do
assert "Returning a trueish value (non nil/false) is a success" do
true
end
end
suite "Failure" do
assert "Returning a falsish value (nil/false) is a failure" do
false