Created
April 7, 2011 22:45
-
-
Save ahoward/908947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## TODO wtf!? there must be an easier way... please help! | |
# | |
def mock_controller | |
require 'action_dispatch/testing/test_request.rb' | |
require 'action_dispatch/testing/test_response.rb' | |
store = ActiveSupport::Cache::MemoryStore.new | |
controller = ApplicationController.new | |
controller.perform_caching = true | |
controller.cache_store = store | |
request = ActionDispatch::TestRequest.new | |
response = ActionDispatch::TestResponse.new | |
controller.request = request | |
controller.response = response | |
controller.send(:initialize_template_class, response) | |
controller.send(:assign_shortcuts, request, response) | |
controller.send(:default_url_options).merge!(DefaultUrlOptions) if defined?(DefaultUrlOptions) | |
controller | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't know if this is actually an improvement, but it's shorter.
https://gist.github.com/909415