RSpec Core
Running examples with a given tag
Adding tags to “describe” or “it” blocks allows you to run only those examples with a given tag. Use the --tag (or -t) option to run examples that match a specified tag. The tag can be a simple name or a name:value pair.
-
If a simple name is supplied, only examples with
:name => truewill run. For example,rspec <spec_file> --tag smokewould run the example tagged with “Smoke”.describe '#Tests' do it 'runs the smoke test', :smoke => true do end it 'runs the regression tests', :regression => true do end it 'runs the acceptance tests', :acceptance => true do end end -
If a
name:valuepair is given, examples withname => valuewill run,where value is always a string. For example,rspec <spec_file> --tag testId:101would run the example tagged withtestId“101”.describe '#Tests' do it 'runs the test with id 99', :testId => 99 do end it 'runs the test with id 101', :testId => 101 do end end