actionview-component 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +43 -55
- data/actionview-component.gemspec +2 -2
- data/app/controllers/rails/components_controller.rb +4 -4
- data/lib/action_view/component.rb +1 -21
- data/lib/action_view/component/base.rb +1 -262
- data/lib/action_view/component/preview.rb +1 -72
- data/lib/action_view/component/railtie.rb +1 -1
- data/lib/action_view/component/test_case.rb +1 -4
- data/lib/rails/generators/component/component_generator.rb +1 -1
- data/lib/rails/generators/test_unit/templates/component_test.rb.tt +1 -1
- data/lib/view_component.rb +29 -0
- data/lib/view_component/base.rb +273 -0
- data/lib/view_component/conversion.rb +9 -0
- data/lib/view_component/engine.rb +65 -0
- data/lib/view_component/preview.rb +77 -0
- data/lib/view_component/previewable.rb +25 -0
- data/lib/view_component/render_monkey_patch.rb +31 -0
- data/lib/view_component/rendering_monkey_patch.rb +13 -0
- data/lib/view_component/template_error.rb +9 -0
- data/lib/view_component/test_case.rb +9 -0
- data/lib/view_component/test_helpers.rb +43 -0
- data/lib/view_component/version.rb +11 -0
- data/script/console +1 -1
- metadata +14 -10
- data/lib/action_view/component/conversion.rb +0 -11
- data/lib/action_view/component/engine.rb +0 -67
- data/lib/action_view/component/previewable.rb +0 -27
- data/lib/action_view/component/render_monkey_patch.rb +0 -34
- data/lib/action_view/component/rendering_monkey_patch.rb +0 -15
- data/lib/action_view/component/template_error.rb +0 -11
- data/lib/action_view/component/test_helpers.rb +0 -45
- data/lib/action_view/component/version.rb +0 -13
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "capybara/minitest"
|
4
|
-
|
5
|
-
module ActionView
|
6
|
-
module Component
|
7
|
-
module TestHelpers
|
8
|
-
include Capybara::Minitest::Assertions
|
9
|
-
|
10
|
-
def page
|
11
|
-
Capybara::Node::Simple.new(@raw)
|
12
|
-
end
|
13
|
-
|
14
|
-
def render_inline(component, **args, &block)
|
15
|
-
@raw = controller.view_context.render(component, args, &block)
|
16
|
-
|
17
|
-
Nokogiri::HTML.fragment(@raw)
|
18
|
-
end
|
19
|
-
|
20
|
-
def controller
|
21
|
-
@controller ||= Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
|
22
|
-
end
|
23
|
-
|
24
|
-
def request
|
25
|
-
@request ||= ActionDispatch::TestRequest.create
|
26
|
-
end
|
27
|
-
|
28
|
-
def render_component(component, **args, &block)
|
29
|
-
ActiveSupport::Deprecation.warn(
|
30
|
-
"`render_component` has been deprecated in favor of `render_inline`, and will be removed in v2.0.0."
|
31
|
-
)
|
32
|
-
|
33
|
-
render_inline(component, args, &block)
|
34
|
-
end
|
35
|
-
|
36
|
-
def with_variant(variant)
|
37
|
-
old_variants = controller.view_context.lookup_context.variants
|
38
|
-
|
39
|
-
controller.view_context.lookup_context.variants = variant
|
40
|
-
yield
|
41
|
-
controller.view_context.lookup_context.variants = old_variants
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|