2009-05-20 20:11:41 -04:00
|
|
|
require 'active_support/all'
|
2010-01-04 20:00:47 -05:00
|
|
|
require 'active_support/test_case'
|
2008-11-24 10:58:52 -05:00
|
|
|
require 'action_controller'
|
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
|
2010-02-28 03:21:12 -05:00
|
|
|
app = Rails.application
|
|
|
|
session = ActionDispatch::Integration::Session.new(app)
|
2006-03-01 11:22:26 -05:00
|
|
|
yield session if block_given?
|
|
|
|
session
|
2006-03-02 22:00:55 -05:00
|
|
|
end
|
|
|
|
|
2010-01-24 15:21:37 -05:00
|
|
|
# reloads the environment
|
|
|
|
def reload!(print=true)
|
|
|
|
puts "Reloading..." if print
|
2010-02-27 20:29:28 -05:00
|
|
|
# This triggers the to_prepare callbacks
|
2010-02-27 20:28:29 -05:00
|
|
|
ActionDispatch::Callbacks.new(Proc.new {}, false).call({})
|
2007-09-25 21:24:07 -04:00
|
|
|
true
|
2006-03-03 16:24:39 -05:00
|
|
|
end
|