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
Started | |
. | |
Finished in 0.000295 seconds. | |
1 tests, 1 assertions, 0 failures, 0 errors |
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
# Copyright 2009 Damian Janowski. MIT License. | |
# http://gist.github.com/100655 | |
# | |
# Very simple script to handle Gem dependencies. | |
# It supports a basic vendoring system | |
# (just gem unpack to ./vendor) | |
# | |
# List your dependencies below and require this | |
# file at the very top of your program (think | |
# of it as a replacement for your require "rubygems"). |
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 PickTest < Test::Unit::TestCase | |
def test_pick | |
hash = {:foo => 1, :bar => 2, :baz => 3} | |
assert_equal({:foo => 1}, hash.pick(:foo)) | |
assert_equal({:foo => 1, :bar => 2}, hash.pick(:foo, :bar)) | |
assert_equal({:foo => 1}, hash.pick(:foo, :miss)) | |
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 'test/unit' | |
class GramosTest < Test::Unit::TestCase | |
def test_regex | |
string = <<-EOS | |
iphone/1.0.0 | |
iphone/beamme/1.3.0 | |
iphone/beamme-pro/1.0.1 | |
iphone/beamme-pitch/1.0.0 | |
EOS |
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 "sinatra" | |
enable :sessions | |
#use Rack::Session::Cookie | |
#use Rack::Session::Pool | |
get '/' do | |
if session[:username] | |
"hi, #{session[:username]}" |
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
# Allows you to use the :session key in your tests | |
# (when using rack-test). | |
# | |
# get "/", {}, :session => {:user => 1} | |
# | |
class Test::Unit::TestCase | |
include Rack::Test::Methods | |
def app | |
Sinatra::Application |
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
# helpers do | |
# def page | |
# @page ||= Page.new | |
# end | |
# end | |
class Page | |
attr_accessor :title | |
def initialize |
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
# This assumes you have the latest Ruby 1.9 installed via MacPorts: | |
# | |
# $ sudo port sync | |
# $ sudo port install ruby19 | |
# | |
# Make sure there are no trails of columnize, linecache, ruby-debug-base and ruby-debug. | |
for name in columnize linecache ruby-debug-base ruby-debug | |
do | |
(gem1.9 list | grep ^$name >/dev/null) && sudo gem1.9 uninstall -a -x -I $name | |
find /opt/local/lib/ruby1.9/gems/1.9.1/gems -name "$name*" -type d -maxdepth 1 -print0 | sudo xargs -0 rm -rf |
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
# Finds all files in /opt/local/bin that are meant to be run | |
# with ruby1.9 (but don't have the 1.9 postfix) and renames them. | |
fixruby19binaries() { | |
for file in $(find /opt/local/bin -type f); | |
do | |
if [[ "$(head -n1 $file)" =~ "ruby1.9" ]]; then | |
newfile=$(echo "$file" | sed -e 's/\(1\.9\)*$/1.9/') | |
if [[ ! $file == $newfile ]]; then | |
echo "Fixing $file => $newfile" |
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 "thor" | |
class App < Thor | |
desc "spec", "Run RSpec" | |
def spec | |
rake do | |
require "spec/rake/spectask" | |
Spec::Rake::SpecTask.new(:default) do |t| |