toptal / crystalball

Regression Test Selection library for your RSpec test suite
https://toptal.github.io/crystalball/
MIT License
323 stars 41 forks source link

is it possible to pass something like --exclude-pattern "**/models/*_spec.rb"? #99

Closed noralin closed 5 years ago

noralin commented 5 years ago

Is it possible to run bundle exec crystalball --exclude-pattern "**/models/*_spec.rb" and exclude running of specified specs? If not, can you advise how to exclude running of certain specs?

Thanks!

pluff commented 5 years ago

TL:DR no it's not possible to exclude some specific specs via --exclude-pattern option

You can actually pass any options RSpec accepts to Crystalball and it'll work the same as in RSpec. However due to nature how RSpec filtering works it will not exclude specs from a run. E.g.

rspec --exclude-pattern "spec/my_spec.rb" spec/my_spec.rb # Pattern is ignored
rspec --exclude-pattern "spec/my_spec.rb" spec/my_spec.rb[1:1] # Pattern is ignored
rspec --exclude-pattern "spec/my_spec.rb" spec # Pattern is applied

Crystalball runs specific examples so --exclude-pattern option is ignored by RSpec.

However you can extend Crystalball runner and add your custom logic here: https://github.com/toptal/crystalball/blob/master/lib/crystalball/rspec/runner.rb#L70-L73

You'll have to specify your custom runner in crystalball.yml config file like this:

runner_class_name: 'MyCrystalballRunner'
requires:
  - "path/to/my_crystalball_runner"
noralin commented 5 years ago

Ohh that makes sense and is consistent with what I'm observing, will add a custom runner as suggested, thanks!