Rake task does not respect 'pattern' flag
Created by: enkessler
Subject of the issue
RSpec CLI options read from a configuration file are treated differently depending on if they are used with the RSpec CLI or the RSpec Rake task. In particular, the --pattern
flag is being ignored when running with the Rake task but works fine with the CLI.
Your environment
- Ruby version: Ruby 3.0
- rspec-core version: 3.10.1
Steps to reproduce
Here's a tiny repository: https://github.com/enkessler/RSpecRakeTaskIssue
From the project root,
- Run
bundle exec rspec
- See both tests run and an HTML file is created
- Delete the HTML report file
- Run
bundle exec rake run_rspec_tests
- See that no tests are run but an HTML file is still created (thus showing that the options in
.rspec
are, in fact, being used)
Expected behavior
I would expect the pattern specified in the .rspec
file to be used in both cases.
Actual behavior
The Rake task does use the values in the .rspec
file but appears to explicitly override the pattern flag. I see rspec --pattern 'spec/**{,/*/**}/*_spec.rb'
appearing in the console output of the second command. As if the Rake task runs its own RSpec process but doesn't just run it as plain old rspec
.