Sha256: 78d4856e890ff9241245ea357381638142a831e7e7370b131998638861f9cb61

Contents?: true

Size: 570 Bytes

Versions: 4

Compression:

Stored size: 570 Bytes

Contents

module ViewComponentV2TestHelpers
  def vc_test_controller
    @vc_test_controller ||= __vc_test_helpers_build_controller(ViewComponent::Base.test_controller.constantize)
  end

  def __vc_test_helpers_build_controller(klass)
    klass.new.tap { |c| c.request = vc_test_request }.extend(Rails.application.routes.url_helpers)
  end

  def vc_test_request
    require "action_controller/test_case"

    @vc_test_request ||=
      begin
        out = ActionDispatch::TestRequest.create
        out.session = ActionController::TestSession.new
        out
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight-gallery-4.6.4 spec/view_component_v2_test_helpers.rb
blacklight-gallery-4.6.3 spec/view_component_v2_test_helpers.rb
blacklight-gallery-4.6.2 spec/view_component_v2_test_helpers.rb
blacklight-gallery-4.6.1 spec/view_component_v2_test_helpers.rb