-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Description
Hi!
As described here https://viewcomponent.org/guide/previews.html#use-with-rspec - to use previews with rspec you just need to configure paths
# config/application.rb
config.view_component.previews.paths << "#{Rails.root}/spec/components/previews"
I have the following initializer
Rails.application.config.view_component.preview_paths << Rails.root.join("spec/components/previews").to_s
Rails.application.config.view_component.default_preview_layout = "component_preview"
Rails.application.config.view_component.generate.sidecar = true
and when I try to start app I see
cosmoport ❯ rails console [master] ≡5 !6 ?30
/Users/alec/Code/Internal/CosmoPort/cosmoport/config/initializers/view_component.rb:1:in '<main>': undefined method '<<' for nil (NoMethodError)
Rails.application.config.view_component.preview_paths << Rails.root.join("spec/components/previews").to_s
^^
from /Users/alec/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/railties-8.0.2/lib/rails/engine.rb:693:in 'Kernel#load'
from /Users/alec/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/railties-8.0.2/lib/rails/engine.rb:693:in 'block in Rails::Engine#load_config_in
itializer'
from /Users/alec/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/activesupport-8.0.2/lib/active_support/notifications.rb:212:in 'ActiveSupport::N
otifications.instrument'
But Rails.root.join("spec/components/previews").to_s
is set
cosmoport ❯ rails console
Type 'jobs_help' to see how to connect to the available job servers to manage jobs
Loading development environment (Rails 8.0.2)
cosmoport(dev)> Rails.root.join("spec/components/previews").to_s
cosmoport(dev)>
=> "/Users/alec/Code/Internal/CosmoPort/cosmoport/spec/components/previews"
cosmoport(dev)>
Whats wrong?
Metadata
Metadata
Assignees
Labels
No labels