CafeHey
CafeHey

Reputation: 5800

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.

Upvotes: 1

Views: 805

Answers (1)

Povilas Jurčys
Povilas Jurčys

Reputation: 176

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

Upvotes: 2

Related Questions