Search code examples
ruby-on-railsrubyrspectdd

Rspec automatically run file which are having _spec suffix but if I want to other file also which does not have _spec then what should i do?


In rails I need that when I run rspec . it will consider all file which are inside the spec directory. As of now it is considering only those file which is having _spec suffix. How can I do it , any idea ?

Thanks


Solution

  • to include other file name suffixes, you can pass a param when running rspec as shown in the docs here, like this, to include files ending in _spec.rb and _test.rb.

    rspec -P "**/*_test.rb,**/*_spec.rb"
    

    You can also include this param in a .rspec file in the root of your project that passes this pattern in automatically, like this in the .rspec file:

    --pattern "**/*_test.rb,**/*_spec.rb"