2006-03-18 09:27:36 -05:00
|
|
|
require 'action_controller/integration'
|
2006-03-01 10:52:40 -05:00
|
|
|
|
|
|
|
# work around the at_exit hook in test/unit, which kills IRB
|
2007-09-25 04:51:06 -04:00
|
|
|
Test::Unit.run = true if Test::Unit.respond_to?(:run=)
|
2006-03-01 10:52:40 -05:00
|
|
|
|
2006-03-01 11:22:26 -05:00
|
|
|
# reference the global "app" instance, created on demand. To recreate the
|
|
|
|
# instance, pass a non-false value as the parameter.
|
2006-03-01 10:52:40 -05:00
|
|
|
def app(create=false)
|
|
|
|
@app_integration_instance = nil if create
|
2006-03-01 11:22:26 -05:00
|
|
|
@app_integration_instance ||= new_session do |sess|
|
2006-03-25 14:43:40 -05:00
|
|
|
sess.host! "www.example.com"
|
2006-03-01 10:52:40 -05:00
|
|
|
end
|
2006-03-01 11:22:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# create a new session. If a block is given, the new session will be yielded
|
|
|
|
# to the block before being returned.
|
|
|
|
def new_session
|
|
|
|
session = ActionController::Integration::Session.new
|
|
|
|
yield session if block_given?
|
|
|
|
session
|
2006-03-02 22:00:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
#reloads the environment
|
|
|
|
def reload!
|
|
|
|
puts "Reloading..."
|
2007-09-25 21:24:07 -04:00
|
|
|
dispatcher = ActionController::Dispatcher.new($stdout)
|
2008-04-17 18:49:03 -04:00
|
|
|
dispatcher.cleanup_application
|
|
|
|
dispatcher.reload_application
|
2007-09-25 21:24:07 -04:00
|
|
|
true
|
2006-03-03 16:24:39 -05:00
|
|
|
end
|