Sha256: f43521cde8268225d45b144772cc0f5c176a3f0363954f05cb567639907e22e0
Contents?: true
Size: 877 Bytes
Versions: 1
Compression:
Stored size: 877 Bytes
Contents
# frozen_string_literal: true require "capybara/minitest" module ViewComponent module TestHelpers include Capybara::Minitest::Assertions def page Capybara::Node::Simple.new(@raw) end def render_inline(component, **args, &block) @raw = controller.view_context.render(component, args, &block) Nokogiri::HTML.fragment(@raw) end def controller @controller ||= Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers) end def request @request ||= ActionDispatch::TestRequest.create end def with_variant(variant) old_variants = controller.view_context.lookup_context.variants controller.view_context.lookup_context.variants = variant yield controller.view_context.lookup_context.variants = old_variants end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
actionview-component-1.15.0 | lib/view_component/test_helpers.rb |