Hi Marcelo Thanks for bringing this to the mailing list, unfortunately thats something we wouldn’t be interested in adding to rspec-rails, for a couple of reasons.
The main reason being we don’t support 3rd party libraries other than Rails own dependencies directly within rspec-rails, given the size of the rails eco system this would lead to massive feature bloat on our part, we prefer to provide the tools for other gems to hook into us, even if it’s just with a `rspec-view_component` style gem etc. We also consider `infer_spec_type_from_file_location!` to be a legacy feature for older rails test suites so don’t want to encourage further adoption (we’d like to deprecate it and remove it one day). However you can add the type yourself to get the functionality you want, rspec-rails uses the public rspec api’s to do this like so: RSpec.configure do |c| c.define_derived_metadata(file_path: /spec[\\\/]components[\\\/]/) do |metadata| metadata[:type] ||= :component end end This would be added to your spec helper and should allow you to not have to declare the component type manually, you could even suggest it to the view_component authors as part of any test helpers they have. Cheers Jon ---------------- [email protected] https://jonrowe.co.uk On 15 October 2020 at 22:45, Marcelo Lauxen wrote: > Hello guys, I was ready to open a feature request, but I'm not sure if it > would make sense for rspec-rails so I'm asking about this here. > > This gem github/view_component (https://github.com/github/view_component) > allow us build components for rails, and their convention is put specs on > "spec/components", we need add TestHelpers > github/view_component#setting-up-rspec > (https://github.com/github/view_component#setting-up-rspec) on the > configuration for specs of :component type and thats fine, but the only think > which is frustating me is the fact that rspec-rails isn't able to infer the > type of the spec based on the file location, because the directory mappings > doesn't include `spec/components` rspec/rails/configuration.rb#L28 > (https://github.com/rspec/rspec-rails/blob/main/lib/rspec/rails/configuration.rb#L28) > and at our projects we use the infer_spec_type_from_file_location! to avoid > the needing of set the spec type, but only for view_components we need define > the type. > > In theory only add "component: %w[spec components]" to the directory mappings > would be enough, but because view_component isn't a rails feature I'm not > sure if this would make sense to the project and maybe the best approach > would be set the type of the spec on each file for this cases. > > What is your opinion on this? I'm a newbie on ruby/rails/rspec stack and > maybe I'm saying a lot of bullshit here (my English is not the best, too), > sorry for anything. > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/dejalu-217-5562a0e3-bb7d-4115-b9b8-8c9a595359af%40jonrowe.co.uk.
