Skip to content

Instantly share code, notes, and snippets.

@jferris
Created January 22, 2010 20:02
Show Gist options
  • Select an option

  • Save jferris/284084 to your computer and use it in GitHub Desktop.

Select an option

Save jferris/284084 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'action_controller'
class StandaloneController < ActionController::Base
def index
render :text => 'Hello'
end
end
# blows up without session config otherwise
ActionController::Base.session_store = nil
# usually looks for controllers in app/controllers/**
ActionController::Routing.use_controllers!(['standalone'])
ActionController::Routing::Routes.load_routes!
dispatcher = ActionController::Dispatcher.new
env = Rack::MockRequest.env_for('/standalone/index')
status, headers, body = dispatcher.call(env).to_a
puts "HTTP #{status}"
body.each do |part|
print part
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment