Exclude pattern for rspec runner
Created by: jmondo
I want to be able to exclude certain directories from running when I run the rspec
command. Like, the opposite of --pattern
... --exclude-pattern
!
A good use case (the one I want to use it for) is to run all the non-feature specs (all the specs except the ones under spec/features
).
rspec --exclude-pattern 'spec/features/**/*_spec.rb'
Or as a rake task:
RSpec::Core::RakeTask.new(:spec_non_features) do |t|
t.exclude_pattern = "./spec/features/**/*_spec.rb"
end
Combined with a task to run only the features (using existing--pattern
), you have a lot of power. You could, for instance, make a rake task that runs the fast tests first, then the features. And if one of the unit tests fails, kill the run before the features start.
Like this:
task spec: ['spec_non_features', 'spec_features']
So, have other people been looking for this, or am I the only one. :)