File tree Expand file tree Collapse file tree
lib/view_component/scoped_styles Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ class Railtie < Rails::Railtie
2222
2323 class << self
2424 def component_path
25- Rails . root . join ( "app/components/**/*.rb" )
25+ Rails . root . join (
26+ ViewComponent ::ScopedStyles . configuration . components_path ,
27+ "**" ,
28+ "*.rb"
29+ )
2630 end
2731
2832 def load_and_register_components
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ RSpec . describe ViewComponent ::ScopedStyles ::Railtie do
4+ describe ".component_path" do
5+ let ( :rails_root ) { Pathname . new ( "/tmp/myapp" ) }
6+
7+ before do
8+ allow ( Rails ) . to receive ( :root ) . and_return ( rails_root )
9+ end
10+
11+ after do
12+ ViewComponent ::ScopedStyles . configuration . components_path =
13+ File . join ( "app" , "components" )
14+ end
15+
16+ it "uses the configured components_path" do
17+ ViewComponent ::ScopedStyles . configuration . components_path =
18+ File . join ( "app" , "view_components" )
19+
20+ expect ( described_class . component_path . to_s ) . to eq (
21+ "/tmp/myapp/app/view_components/**/*.rb"
22+ )
23+ end
24+
25+ it "defaults to app/components" do
26+ expect ( described_class . component_path . to_s ) . to eq (
27+ "/tmp/myapp/app/components/**/*.rb"
28+ )
29+ end
30+ end
31+ end
Original file line number Diff line number Diff line change 66 end
77
88 describe "Configuration" do
9- it "defaults assets_path and stylesheet_name" do
9+ it "defaults components_path, assets_path, and stylesheet_name" do
1010 config = ViewComponent ::ScopedStyles ::Configuration . new
1111
12+ expect ( config . components_path ) . to eq ( File . join ( "app" , "components" ) )
1213 expect ( config . assets_path ) . to eq ( File . join ( "app" , "assets" , "stylesheets" ) )
1314 expect ( config . stylesheet_name ) . to eq ( "components.scoped.css" )
1415 end
You can’t perform that action at this time.
0 commit comments