Skip to content

Add a config entry to specify where bin/rails generate component should create spec file #632

@phacks

Description

@phacks

Feature request

It would be great to have a new config entry to specify the path and suffix which the command will use to create specs, e.g.

config.view_component.test_path = "#{Rails.root}/spec/components"
config.view_component.test_file_suffix = "spec"

Which would yield the following result on running the command:

bin/rails generate component Example title content
      invoke  test_unit
      create  spec/components/example_component_spec.rb

Motivation

I use the bin/rails generate component command to create new components, but have to manually move the generated spec file from test/components to spec/components as we’re using Rspec, and rename it to match other spec files. Adding a config entry would avoid that.

Happy to work on a PR for that! I would just want to make sure first if we want to go with my config suggestion above or go with something like config.view_components.test_framework == 'rspec' that would apply the relevant defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions