I am using rspec(3.5) to run my tests and building a CLI with it. Currently considering rake. In my CLI, I would like it to be able to find all of the tags available in my spec folders and provide it as an option to run as tests BEFORE RUNNING THE RSPEC.
I've been prying through spec_helper and haven't been able to find the tag information. My understanding is, rspec CLI itself accepts all of the tags as input, it then goes through all of the files to see if each of them matches the tags, if it does, rspec will run them.
I would like to reverse this workflow -
Right now I'm stuck at step 1, finding all the tags. Suppose, how do I scan through all the spec folders without running the test, and expose the tags somewhere?
Sample Excerpt from my code. The ":api" is the tag I'm referring to.
describe 'Oh Title: Oh after title', :api, :data_key => "Oh my meta_data", :feature => "Oh my feature" do
it 'oh my explanation' :data_key=> 'oh my meta_data' do |e|
#blah blah#
end
end
I know this is like 2 years late, but I am in the same spot you were in. Here is what I did.
custom rspec formatter
# spec/support/formatters/ci_rspec_run_files.rb
module Formatters
class CiRspecRunFiles
RSpec::Core::Formatters.register self, :example_started
def initialize(output)
@output = output
end
def example_started(notification)
@output << "#{notification.example.id}\n"
end
end
end
run
$ rspec --dry-run --tag ci:flakey --require ./spec/support/formatters/ci_rspec_run_files.rb -f Formatters::CiRspecRunFiles --out tmp/flakey_specs.txt
result
$ cat tmp/flakey_specs.txt
./spec/models/flakey_spec.rb[1:3:6:4:1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With