Commit f1b36aa4 authored by Mark Lapierre's avatar Mark Lapierre

Quarantine spec code review changes

- Clarify message shown when skipping quarantined tests because
they don't have all the specified tags.
- Simplify rejecting item from array
- Remove 'pass' from example descriptions to avoid confusion
parent f802d496
...@@ -14,7 +14,7 @@ RSpec.configure do |config| ...@@ -14,7 +14,7 @@ RSpec.configure do |config|
# using `--tag quarantine --tag smoke`, without this check we'd end up # using `--tag quarantine --tag smoke`, without this check we'd end up
# running that ldap test as well. # running that ldap test as well.
if config.inclusion_filter[:quarantine] if config.inclusion_filter[:quarantine]
skip('Running only tagged tests in quarantine') unless quarantine_and_optional_other_tag?(example, config) skip("Running tests tagged with all of #{config.inclusion_filter.rules.keys}") unless quarantine_and_optional_other_tag?(example, config)
end end
end end
...@@ -50,8 +50,7 @@ end ...@@ -50,8 +50,7 @@ end
def quarantine_and_optional_other_tag?(example, config) def quarantine_and_optional_other_tag?(example, config)
return false unless example.metadata.keys.include? :quarantine return false unless example.metadata.keys.include? :quarantine
filters_other_than_quarantine = config.inclusion_filter.rules.keys.dup filters_other_than_quarantine = config.inclusion_filter.rules.keys.reject { |key| key == :quarantine }
filters_other_than_quarantine.delete :quarantine
return true if filters_other_than_quarantine.empty? return true if filters_other_than_quarantine.empty?
......
...@@ -4,9 +4,9 @@ describe 'rspec config tests' do ...@@ -4,9 +4,9 @@ describe 'rspec config tests' do
let(:group) do let(:group) do
RSpec.describe do RSpec.describe do
shared_examples 'passing tests' do shared_examples 'passing tests' do
example 'pass: not in quarantine' do example 'not in quarantine' do
end end
example 'pass: in quarantine', :quarantine do example 'in quarantine', :quarantine do
end end
end end
...@@ -28,10 +28,10 @@ describe 'rspec config tests' do ...@@ -28,10 +28,10 @@ describe 'rspec config tests' do
foo_examples = foo_context.descendant_filtered_examples foo_examples = foo_context.descendant_filtered_examples
expect(foo_examples.count).to eq(2) expect(foo_examples.count).to eq(2)
ex = foo_examples.find { |e| e.description == "pass: not in quarantine" } ex = foo_examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
ex = foo_examples.find { |e| e.description == "pass: in quarantine" } ex = foo_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('In quarantine') expect(ex.execution_result.pending_message).to eq('In quarantine')
...@@ -39,10 +39,10 @@ describe 'rspec config tests' do ...@@ -39,10 +39,10 @@ describe 'rspec config tests' do
default_examples = default_context.descendant_filtered_examples default_examples = default_context.descendant_filtered_examples
expect(default_examples.count).to eq(2) expect(default_examples.count).to eq(2)
ex = default_examples.find { |e| e.description == "pass: not in quarantine" } ex = default_examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
ex = default_examples.find { |e| e.description == "pass: in quarantine" } ex = default_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('In quarantine') expect(ex.execution_result.pending_message).to eq('In quarantine')
end end
...@@ -67,14 +67,14 @@ describe 'rspec config tests' do ...@@ -67,14 +67,14 @@ describe 'rspec config tests' do
foo_examples = foo_context.descendant_filtered_examples foo_examples = foo_context.descendant_filtered_examples
expect(foo_examples.count).to be(1) expect(foo_examples.count).to be(1)
ex = foo_examples.find { |e| e.description == "pass: in quarantine" } ex = foo_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
default_context = group.children.find { |c| c.description == "default" } default_context = group.children.find { |c| c.description == "default" }
default_examples = default_context.descendant_filtered_examples default_examples = default_context.descendant_filtered_examples
expect(default_examples.count).to be(1) expect(default_examples.count).to be(1)
ex = default_examples.find { |e| e.description == "pass: in quarantine" } ex = default_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
end end
end end
...@@ -103,10 +103,10 @@ describe 'rspec config tests' do ...@@ -103,10 +103,10 @@ describe 'rspec config tests' do
foo_examples = foo_context.descendant_filtered_examples foo_examples = foo_context.descendant_filtered_examples
expect(foo_examples.count).to eq(2) expect(foo_examples.count).to eq(2)
ex = foo_examples.find { |e| e.description == "pass: not in quarantine" } ex = foo_examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
ex = foo_examples.find { |e| e.description == "pass: in quarantine" } ex = foo_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('In quarantine') expect(ex.execution_result.pending_message).to eq('In quarantine')
end end
...@@ -131,11 +131,11 @@ describe 'rspec config tests' do ...@@ -131,11 +131,11 @@ describe 'rspec config tests' do
foo_examples = foo_context.descendant_filtered_examples foo_examples = foo_context.descendant_filtered_examples
expect(foo_examples.count).to eq(2) expect(foo_examples.count).to eq(2)
ex = foo_examples.find { |e| e.description == "pass: not in quarantine" } ex = foo_examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('Running only tagged tests in quarantine') expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:quarantine, :foo]')
ex = foo_examples.find { |e| e.description == "pass: in quarantine" } ex = foo_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
end end
...@@ -145,9 +145,9 @@ describe 'rspec config tests' do ...@@ -145,9 +145,9 @@ describe 'rspec config tests' do
default_examples = default_context.descendant_filtered_examples default_examples = default_context.descendant_filtered_examples
expect(default_examples.count).to eq(1) expect(default_examples.count).to eq(1)
ex = default_examples.find { |e| e.description == "pass: in quarantine" } ex = default_examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('Running only tagged tests in quarantine') expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:quarantine, :foo]')
end end
end end
...@@ -248,14 +248,14 @@ describe 'rspec config tests' do ...@@ -248,14 +248,14 @@ describe 'rspec config tests' do
ex = group.examples.find { |e| e.description == "foo" } ex = group.examples.find { |e| e.description == "foo" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('Running only tagged tests in quarantine') expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:bar, :foo, :quarantine]')
ex = group.examples.find { |e| e.description == "bar and quarantine" } ex = group.examples.find { |e| e.description == "bar and quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
ex = group.examples.find { |e| e.description == "foo and bar" } ex = group.examples.find { |e| e.description == "foo and bar" }
expect(ex.execution_result.status).to eq(:pending) expect(ex.execution_result.status).to eq(:pending)
expect(ex.execution_result.pending_message).to eq('Running only tagged tests in quarantine') expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:bar, :foo, :quarantine]')
ex = group.examples.find { |e| e.description == "foo, bar, and quarantine" } ex = group.examples.find { |e| e.description == "foo, bar, and quarantine" }
expect(ex.execution_result.status).to eq(:passed) expect(ex.execution_result.status).to eq(:passed)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment