Sha256: 4a2535326011efd28cf668ff4d08f39d3d25d0c139ab36c1a4ffe50e81c06bf6
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module ControllerHelpers def build_controller let(:controller_class) do Class.new(ActionController::Metal).tap do |klass| klass.instance_eval do def helper_method(*_); end end klass.send :include, ActionController::Rendering klass.send :include, ActionController::Flash klass.send :include, AbstractController::Rendering klass.send :include, ActionController::Rendering klass.send :cattr_accessor, :spec klass.spec = self end end let(:request) do ActionDispatch::TestRequest.new(ActionDispatch::TestRequest::DEFAULT_ENV.dup).tap do |request| request.class_eval do def flash @env[ActionDispatch::Flash::KEY] ||= ActionDispatch::Flash::FlashHash.new end end end end let(:controller) do controller_class.new.tap do |controller| controller.instance_variable_set(:@_request, request) end end end def controller_action(&blk) before do controller_class.send :define_method, :index do instance_eval(&blk) render text: "" end controller.dispatch(:index, request) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
warp-1.0.0 | spec/support/controller_helpers.rb |