max
max

Reputation: 102134

Run each RSpec spec file individually

I have recently split the test bootstrapping process for a large repository into separate spec_helper and rails_helper files.

The specs currently pass when I run rspec spec but fail on Travis CI since it runs each spec file folded (in isolation):

rspec spec/foo/bar_spec.rb
rspec spec/foo/baz_spec.rb
# ...

What is a simple way to run each spec isolated and gather the failed specs? There are about 50 of them so I would rather not do it manually.

Upvotes: 3

Views: 322

Answers (1)

zetetic
zetetic

Reputation: 47548

Assuming you are on MacOs/Linux, specs are in ./spec and suffixed _spec.rb:

find spec -name '*_spec.rb' -exec bundle exec rspec {} \;

or

find spec -name '*_spec.rb' | xargs -I {} bundle exec rspec {}

Upvotes: 3

Related Questions