Skip to content

Instantly share code, notes, and snippets.

View tie-rack's full-sized avatar

Christopher Shea tie-rack

View GitHub Profile
# Run the little Sinatra app on port 3000 and the big Rails app on
# port 3001. Run this file and hit them both at port 4000.
require 'rubygems'
require 'rack/proxy'
require 'thin'
class LittleProxy < Rack::Proxy
def rewrite_env(env)
if env['PATH_INFO'].match(/^\/little\//)
escape ^t^t
startup_message off
hardstatus alwayslastline
hardstatus string "%?%{yk}%-Lw%?%{wb}%n*%f %t%?(%u)%?%?%{yk}%+Lw%?%{yk}"
class BlankSlate
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
end
class Delegated < BlankSlate
attr_reader :delegate
def initialize(delegate)
@delegate = delegate
end
# A few assumptions are made here:
#
# 1. You want your javascript tests in test/javascript
# 2. Your jsunittest.js file is called that (you've stripped the version)
# 3. You've got a jsunittest.css file in the same place
# 4. You've set JSUNITTEST as the path to where the jsunittest files live
#
# Run it like this: thor jsunittest:test path/to/your/js.js
require 'pathname'
class JsUnit < Thor
desc 'create_test_directory', 'Create the javascript test directory'
def create_test_directory
FileUtils.mkdir_p(test_path)
end
desc 'create_test_file FILE', 'Create a JsUnit test page for FILE'
def create_test_file(filename)
create_test_directory
class Appointment < ActiveRecord::Base
attr_reader :availability
def full?
availability < 1
end
end
# And then in your view