vendredi 12 avril 2019

Conditionally applying tags in RSpec loop

I have a test file which begins with a .for_each loop. I want to apply a tag to one but not the other.

I could copy/paste the whole file, but that is very inelegant.

The test begins thusly:

[ "item1_name", "item2_name" ].each do |item|
  describe "Test Run on #{ item }" do

Is it possible? The below obviously wont work, but is descriptive of what I'm hoping for:

e.g.:

[ "item1_name", "item2_name" ].each do |item|
  if item == 'item1_name'
    describe "Test Run on #{ item }", :tag do
  else
    describe "Test Run on #{ item }", do
  end

  before :all do
    ...
  end

  ...
  expectations
  ...
end

Aucun commentaire:

Enregistrer un commentaire