class MockApplication def self.env_config {} end def self.routes @routes ||= ActionDispatch::Routing::RouteSet.new end end MockApplication.routes.draw do resource :callback_tests end ::Rails.application = MockApplication ActionController::Base.send :include, RailsLocaleDetection::ControllerMethods ActionController::Base.send :include, Rails.application.routes.url_helpers class CallbackTestsController < ActionController::Base def user_locale :fr end def show if ::Rails.version.to_s < "4.1" render text: current_locale else render plain: current_locale end end end