lib/rails_helper.rb in rails_helper-2.2.0 vs lib/rails_helper.rb in rails_helper-2.2.2

- old
+ new

@@ -1,8 +1,8 @@ class Helper < (defined?(ActionView::Base) ? ActionView::Base : Object) def Helper.version - '2.2.0' + '2.2.2' end def Helper.dependencies { 'rails_current' => [ 'rails_current', ' >= 1.0' ], @@ -67,26 +67,53 @@ end # see ./actionpack/test/controller/caching_test.rb OUCH! # def Helper.mock_controller + require 'rails' + require 'action_controller' require 'action_dispatch/testing/test_request.rb' require 'action_dispatch/testing/test_response.rb' store = ActiveSupport::Cache::MemoryStore.new - controller = ApplicationController.new + controller = mock_controller_class.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(:default_url_options).dup.merge(DefaultUrlOptions.dup) if defined?(DefaultUrlOptions) + singleton_class = + class << controller + self + end + + singleton_class.module_eval do + define_method(:default_url_options) do + @default_url_options ||= ( + defined?(DefaultUrlOptions) ? DefaultUrlOptions.dup : {} + ) + end + end + controller + end + + def Helper.mock_controller_class + unless const_defined?(:Controller) + controller_class = + if defined?(::ApplicationController) + Class.new(::ApplicationController) + else + Class.new(::ActionController::Base) + end + const_set(:Controller, controller_class) + end + return const_get(:Controller) end def Helper.current_controller Current.controller end