Sha256: e0954c3e2d9ecb2f8788ad2490ced444eb80e5409b7d28bbc7724e95d124ee5f
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
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 render_component(component, **args, &block) ActiveSupport::Deprecation.warn( "`render_component` has been deprecated in favor of `render_inline`, and will be removed in v2.0.0." ) render_inline(component, args, &block) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
actionview-component-1.14.1 | lib/view_component/test_helpers.rb |
actionview-component-1.14.0 | lib/view_component/test_helpers.rb |