Search code examples
ruby-on-railsrspecrspec-rails

In rails, how do I run all my model tests when I run bin/rspec?


When I run rspec or bin/rspec it runs all the tests from my features folder.

However this does not run my model tests in my models folders, for that I have to run each one with bin/rspec spec/models/some_model.rb

How do I make bin/rspec run all tests in every folders?

Thanks.


Solution

  • As @jdno said, you need to rename your rspec file from some_model.rb to some_model_spec.rb.

    Although I do not recommend, but RSpec has config option --pattern which you can change. For example, you can add .rspec file in your project path with this:

    # your_project_dir/.rspec
    --pattern 'spec/**/*.rb' 
    

    more info about --pattern option can be found here: https://relishapp.com/rspec/rspec-core/v/3-8/docs/command-line/pattern-option