File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change 9
9
def call
10
10
icon_tag ( "user-line" )
11
11
end
12
- end . new
12
+ end
13
13
14
14
render_inline ( component )
15
15
@@ -42,7 +42,7 @@ def call
42
42
43
43
describe ".stimulus_id" do
44
44
it "returns the stimulus id for the component" do
45
- stub_const ( "SolidusAdmin::Foo::Bar::Component" , Class . new ( described_class ) )
45
+ mock_component ( "SolidusAdmin::Foo::Bar::Component" ) { erb_template "" }
46
46
47
47
expect ( SolidusAdmin ::Foo ::Bar ::Component . stimulus_id ) . to eq ( "foo--bar" )
48
48
expect ( SolidusAdmin ::Foo ::Bar ::Component . new . stimulus_id ) . to eq ( "foo--bar" )
Original file line number Diff line number Diff line change @@ -11,14 +11,9 @@ module ComponentHelpers
11
11
# "Rendered"
12
12
# end
13
13
# end
14
- def mock_component ( &definition )
15
- Class . new ( SolidusAdmin ::BaseComponent ) do
16
- # ViewComponent will complain if we don't fake a class name:
17
- # @see https://github.com/ViewComponent/view_component/blob/5decd07842c48cbad82527daefa3fe9c65a4226a/lib/view_component/base.rb#L371
18
- def self . name
19
- "Foo"
20
- end
21
- end . tap { |klass | klass . class_eval ( &definition ) if definition }
14
+ def mock_component ( class_name = "Foo::Component" , &definition )
15
+ component_class = stub_const ( class_name , Class . new ( described_class , &definition ) )
16
+ component_class . new
22
17
end
23
18
end
24
19
end
You can’t perform that action at this time.
0 commit comments