~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/railties/lib/console_app.rb

  • Committer: Michael Forrest
  • Date: 2010-10-15 16:28:50 UTC
  • Revision ID: michael.forrest@canonical.com-20101015162850-tj2vchanv0kr0dun
refrozeĀ gems

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'active_support/test_case'
 
2
require 'action_controller'
 
3
 
 
4
# work around the at_exit hook in test/unit, which kills IRB
 
5
Test::Unit.run = true if Test::Unit.respond_to?(:run=)
 
6
 
 
7
# reference the global "app" instance, created on demand. To recreate the
 
8
# instance, pass a non-false value as the parameter.
 
9
def app(create=false)
 
10
  @app_integration_instance = nil if create
 
11
  @app_integration_instance ||= new_session do |sess|
 
12
    sess.host! "www.example.com"
 
13
  end
 
14
end
 
15
 
 
16
# create a new session. If a block is given, the new session will be yielded
 
17
# to the block before being returned.
 
18
def new_session
 
19
  session = ActionController::Integration::Session.new
 
20
  yield session if block_given?
 
21
  session
 
22
end
 
23
 
 
24
#reloads the environment
 
25
def reload!
 
26
  puts "Reloading..."
 
27
  Dispatcher.cleanup_application
 
28
  Dispatcher.reload_application
 
29
  true
 
30
end