diff options
Diffstat (limited to 'qa')
-rw-r--r-- | qa/README.md | 23 | ||||
-rw-r--r-- | qa/qa/page/component/note.rb | 6 | ||||
-rw-r--r-- | qa/qa/resource/base.rb | 4 | ||||
-rw-r--r-- | qa/qa/resource/user.rb | 9 | ||||
-rw-r--r-- | qa/qa/runtime/browser.rb | 62 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 38 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb | 6 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb | 3 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb | 11 | ||||
-rw-r--r-- | qa/spec/resource/base_spec.rb | 4 | ||||
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 59 | ||||
-rw-r--r-- | qa/spec/spec_helper.rb | 34 | ||||
-rw-r--r-- | qa/spec/spec_helper_spec.rb | 264 |
13 files changed, 482 insertions, 41 deletions
diff --git a/qa/README.md b/qa/README.md index 08ba59e117d..5e32496ea9f 100644 --- a/qa/README.md +++ b/qa/README.md @@ -86,7 +86,7 @@ The environment variable `QA_COOKIES` can be set to send additional cookies on every request. This is necessary on gitlab.com to direct traffic to the canary fleet. To do this set `QA_COOKIES="gitlab_canary=true"`. -To set multiple cookies, separate them with the `;` character, for example: `QA_COOKIES="cookie1=value;cookie2=value2"` +To set multiple cookies, separate them with the `;` character, for example: `QA_COOKIES="cookie1=value;cookie2=value2"` ### Building a Docker image to test @@ -100,3 +100,24 @@ docker build -t gitlab/gitlab-ce-qa:nightly . ``` [GDK]: https://gitlab.com/gitlab-org/gitlab-development-kit/ + +### Quarantined tests + +Tests can be put in quarantine by assigning `:quarantine` metadata. This means +they will be skipped unless run with `--tag quarantine`. This can be used for +tests that are expected to fail while a fix is in progress (similar to how +[`skip` or `pending`](https://relishapp.com/rspec/rspec-core/v/3-8/docs/pending-and-skipped-examples) + can be used). + +``` +bin/qa Test::Instance::All http://localhost --tag quarantine +``` + +If `quarantine` is used with other tags, tests will only be run if they have at +least one of the tags other than `quarantine`. This is different from how RSpec +tags usually work, where all tags are inclusive. + +For example, suppose one test has `:smoke` and `:quarantine` metadata, and +another test has `:ldap` and `:quarantine` metadata. If the tests are run with +`--tag smoke --tag quarantine`, only the first test will run. The test with +`:ldap` will not run even though it also has `:quarantine`. diff --git a/qa/qa/page/component/note.rb b/qa/qa/page/component/note.rb index 67d7f114786..f5add6bc9b5 100644 --- a/qa/qa/page/component/note.rb +++ b/qa/qa/page/component/note.rb @@ -32,9 +32,13 @@ module QA click_element :comment_button end - def reply_to_discussion(reply_text) + def type_reply_to_discussion(reply_text) all_elements(:discussion_reply).last.click fill_element :reply_input, reply_text + end + + def reply_to_discussion(reply_text) + type_reply_to_discussion(reply_text) click_element :reply_comment_button end diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index dcea144ab74..f325162d1c0 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -126,10 +126,6 @@ module QA mod end - def self.attributes_names - dynamic_attributes.instance_methods(false).sort.grep_v(/=$/) - end - class DSL def initialize(base) @base = base diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb index c26f0c84a1f..b9580d81171 100644 --- a/qa/qa/resource/user.rb +++ b/qa/qa/resource/user.rb @@ -6,9 +6,12 @@ module QA module Resource class User < Base attr_reader :unique_id - attr_writer :username, :password, :name, :email + attr_writer :username, :password attr_accessor :provider, :extern_uid + attribute :name + attribute :email + def initialize @unique_id = SecureRandom.hex(8) end @@ -22,11 +25,11 @@ module QA end def name - @name ||= username + @name ||= api_resource&.dig(:name) || username end def email - @email ||= "#{username}@example.com" + @email ||= api_resource&.dig(:email) || "#{username}@example.com" end def credentials_given? diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index b706d6565d2..0bcf5e693f0 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -40,34 +40,38 @@ module QA return if Capybara.drivers.include?(:chrome) - Capybara.register_driver :chrome do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - # This enables access to logs with `page.driver.manage.get_log(:browser)` - loggingPrefs: { - browser: "ALL", - client: "ALL", - driver: "ALL", - server: "ALL" - } - ) + Capybara.register_driver QA::Runtime::Env.browser do |app| + capabilities = Selenium::WebDriver::Remote::Capabilities.send(QA::Runtime::Env.browser, + # This enables access to logs with `page.driver.manage.get_log(:browser)` + loggingPrefs: { + browser: "ALL", + client: "ALL", + driver: "ALL", + server: "ALL" + }) if QA::Runtime::Env.accept_insecure_certs? capabilities['acceptInsecureCerts'] = true end - options = Selenium::WebDriver::Chrome::Options.new - options.add_argument("window-size=1240,1680") + # QA::Runtime::Env.browser.capitalize will work for every driver type except PhantomJS. + # We will have no use to use PhantomJS so this shouldn't be a problem. + options = Selenium::WebDriver.const_get(QA::Runtime::Env.browser.capitalize)::Options.new + + if QA::Runtime::Env.browser == :chrome + options.add_argument("window-size=1240,1680") - # Chrome won't work properly in a Docker container in sandbox mode - options.add_argument("no-sandbox") + # Chrome won't work properly in a Docker container in sandbox mode + options.add_argument("no-sandbox") - # Run headless by default unless CHROME_HEADLESS is false - if QA::Runtime::Env.chrome_headless? - options.add_argument("headless") + # Run headless by default unless CHROME_HEADLESS is false + if QA::Runtime::Env.chrome_headless? + options.add_argument("headless") - # Chrome documentation says this flag is needed for now - # https://developers.google.com/web/updates/2017/04/headless-chrome#cli - options.add_argument("disable-gpu") + # Chrome documentation says this flag is needed for now + # https://developers.google.com/web/updates/2017/04/headless-chrome#cli + options.add_argument("disable-gpu") + end end # Use the same profile on QA runs if CHROME_REUSE_PROFILE is true. @@ -80,12 +84,18 @@ module QA # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252 options.add_argument("disable-dev-shm-usage") if QA::Runtime::Env.running_in_ci? - Capybara::Selenium::Driver.new( - app, - browser: :chrome, + selenium_options = { + browser: QA::Runtime::Env.browser, clear_local_storage: true, desired_capabilities: capabilities, options: options + } + + selenium_options[:url] = QA::Runtime::Env.remote_grid if QA::Runtime::Env.remote_grid + + Capybara::Selenium::Driver.new( + app, + selenium_options ) end @@ -93,7 +103,7 @@ module QA Capybara::Screenshot.prune_strategy = :keep_last_run # From https://github.com/mattheworiordan/capybara-screenshot/issues/84#issuecomment-41219326 - Capybara::Screenshot.register_driver(:chrome) do |driver, path| + Capybara::Screenshot.register_driver(QA::Runtime::Env.browser) do |driver, path| driver.browser.save_screenshot(path) end @@ -102,8 +112,8 @@ module QA end Capybara.configure do |config| - config.default_driver = :chrome - config.javascript_driver = :chrome + config.default_driver = QA::Runtime::Env.browser + config.javascript_driver = QA::Runtime::Env.browser config.default_max_wait_time = 10 # https://github.com/mattheworiordan/capybara-screenshot/issues/164 config.save_path = ::File.expand_path('../../tmp', __dir__) diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index dae5aa3f794..79b40223d84 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -56,6 +56,34 @@ module QA @personal_access_token ||= ENV['PERSONAL_ACCESS_TOKEN'] end + def remote_grid + # if username specified, password/auth token is required + # can be + # - "http://user:pass@somehost.com/wd/hub" + # - "https://user:pass@somehost.com:443/wd/hub" + # - "http://localhost:4444/wd/hub" + + return unless ENV['QA_REMOTE_GRID'] + + "#{remote_grid_protocol}://#{remote_grid_credentials}#{ENV['QA_REMOTE_GRID']}/wd/hub" + end + + def remote_grid_username + ENV['QA_REMOTE_GRID_USERNAME'] + end + + def remote_grid_access_key + ENV['QA_REMOTE_GRID_ACCESS_KEY'] + end + + def remote_grid_protocol + ENV['QA_REMOTE_GRID_PROTOCOL'] || 'http' + end + + def browser + ENV['QA_BROWSER'].nil? ? :chrome : ENV['QA_BROWSER'].to_sym + end + def user_username ENV['GITLAB_USERNAME'] end @@ -158,6 +186,16 @@ module QA private + def remote_grid_credentials + if remote_grid_username + raise ArgumentError, %Q(Please provide an access key for user "#{remote_grid_username}") unless remote_grid_access_key + + return "#{remote_grid_username}:#{remote_grid_access_key}@" + end + + '' + end + def enabled?(value, default: true) return default if value.nil? diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb index 203338ddf77..3a5d89e6b83 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb @@ -39,11 +39,15 @@ module QA end it 'user views raw email patch' do + user = Resource::User.fabricate_via_api! do |user| + user.username = Runtime::User.username + end + view_commit Page::Project::Commit::Show.perform(&:select_email_patches) - expect(page).to have_content('From: Administrator <admin@example.com>') + expect(page).to have_content("From: #{user.name} <#{user.email}>") expect(page).to have_content('Subject: [PATCH] Add second file') expect(page).to have_content('diff --git a/second b/second') end diff --git a/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb b/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb index 210271705d9..a7d0998d42c 100644 --- a/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb @@ -17,7 +17,8 @@ module QA login end - it 'user creates, edits, clones, and pushes to the wiki' do + # Failure reported: https://gitlab.com/gitlab-org/quality/nightly/issues/24 + it 'user creates, edits, clones, and pushes to the wiki', :quarantine do wiki = Resource::Wiki.fabricate! do |resource| resource.title = 'Home' resource.content = '# My First Wiki Content' diff --git a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb index 5ee8df03d50..5147b17d7ab 100644 --- a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb +++ b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb @@ -98,6 +98,17 @@ module QA resource.value = 'You can see this application secret' end + # Our current Auto DevOps implementation won't update the production + # app if we only update a CI variable with no code change. + # + # Workaround: push new code and use the resultant pipeline. + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = @project + push.commit_message = 'Force a Deployment change by pushing new code' + push.file_name = 'new_file.txt' + push.file_content = 'new file contents' + end + @project.visit! Page::Project::Menu.act { click_ci_cd_pipelines } Page::Project::Pipeline::Index.act { go_to_latest_pipeline } diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb index dc9e16792d3..b8c406ae72a 100644 --- a/qa/spec/resource/base_spec.rb +++ b/qa/spec/resource/base_spec.rb @@ -138,10 +138,6 @@ describe QA::Resource::Base do describe '.attribute' do include_context 'simple resource' - it 'appends new attribute' do - expect(subject.attributes_names).to eq([:no_block, :test, :web_url]) - end - context 'when the attribute is populated via a block' do it 'returns value from the block' do result = subject.fabricate!(resource: resource) diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index ded51d5bb7c..bc0ec08d66d 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -207,4 +207,63 @@ describe QA::Runtime::Env do expect { described_class.can_test? :foo }.to raise_error(ArgumentError, 'Unknown feature "foo"') end end + + describe 'remote grid credentials' do + it 'is blank if username is empty' do + stub_env('QA_REMOTE_GRID_USERNAME', nil) + + expect(described_class.send(:remote_grid_credentials)).to eq('') + end + + it 'throws ArgumentError if GRID_ACCESS_KEY is not specified with USERNAME' do + stub_env('QA_REMOTE_GRID_USERNAME', 'foo') + + expect { described_class.send(:remote_grid_credentials) }.to raise_error(ArgumentError, 'Please provide an access key for user "foo"') + end + + it 'returns a user:key@ combination when all args are satiated' do + stub_env('QA_REMOTE_GRID_USERNAME', 'foo') + stub_env('QA_REMOTE_GRID_ACCESS_KEY', 'bar') + + expect(described_class.send(:remote_grid_credentials)).to eq('foo:bar@') + end + end + + describe '.remote_grid_protocol' do + it 'defaults protocol to http' do + stub_env('QA_REMOTE_GRID_PROTOCOL', nil) + expect(described_class.remote_grid_protocol).to eq('http') + end + end + + describe '.remote_grid' do + it 'is falsey if QA_REMOTE_GRID is not set' do + expect(described_class.remote_grid).to be_falsey + end + + it 'accepts https protocol' do + stub_env('QA_REMOTE_GRID', 'localhost:4444') + stub_env('QA_REMOTE_GRID_PROTOCOL', 'https') + + expect(described_class.remote_grid).to eq('https://localhost:4444/wd/hub') + end + + context 'with credentials' do + it 'has a grid of http://user:key@grid/wd/hub' do + stub_env('QA_REMOTE_GRID_USERNAME', 'foo') + stub_env('QA_REMOTE_GRID_ACCESS_KEY', 'bar') + stub_env('QA_REMOTE_GRID', 'localhost:4444') + + expect(described_class.remote_grid).to eq('http://foo:bar@localhost:4444/wd/hub') + end + end + + context 'without credentials' do + it 'has a grid of http://grid/wd/hub' do + stub_env('QA_REMOTE_GRID', 'localhost:4444') + + expect(described_class.remote_grid).to eq('http://localhost:4444/wd/hub') + end + end + end end diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index 8e01da01340..3537ba7c235 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -5,6 +5,24 @@ Dir[::File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f } RSpec.configure do |config| config.before do |example| QA::Runtime::Logger.debug("Starting test: #{example.full_description}") if QA::Runtime::Env.debug? + + # If quarantine is tagged, skip tests that have other metadata unless + # they're also tagged. This lets us run quarantined tests in a particular + # category without running tests in other categories. + # E.g., if a test is tagged 'smoke' and 'quarantine', and another is tagged + # 'ldap' and 'quarantine', if we wanted to run just quarantined smoke tests + # using `--tag quarantine --tag smoke`, without this check we'd end up + # running that ldap test as well. + if config.inclusion_filter[:quarantine] + skip("Running tests tagged with all of #{config.inclusion_filter.rules.keys}") unless quarantine_and_optional_other_tag?(example, config) + end + end + + config.before(:each, :quarantine) do |example| + # Skip tests in quarantine unless we explicitly focus on them + # We could use an exclusion filter, but this way the test report will list + # the quarantined tests when they're not run so that we're aware of them + skip('In quarantine') unless config.inclusion_filter[:quarantine] end config.expect_with :rspec do |expectations| @@ -22,3 +40,19 @@ RSpec.configure do |config| config.order = :random Kernel.srand config.seed end + +# Checks if a test has the 'quarantine' tag and other tags in the inclusion filter. +# +# Returns true if +# - the example metadata includes the quarantine tag +# - and the metadata and inclusion filter both have any other tag +# - or no other tags are in the inclusion filter +def quarantine_and_optional_other_tag?(example, config) + return false unless example.metadata.keys.include? :quarantine + + filters_other_than_quarantine = config.inclusion_filter.rules.keys.reject { |key| key == :quarantine } + + return true if filters_other_than_quarantine.empty? + + filters_other_than_quarantine.any? { |key| example.metadata.keys.include? key } +end diff --git a/qa/spec/spec_helper_spec.rb b/qa/spec/spec_helper_spec.rb new file mode 100644 index 00000000000..f001200fb52 --- /dev/null +++ b/qa/spec/spec_helper_spec.rb @@ -0,0 +1,264 @@ +# frozen_string_literal: true + +describe 'rspec config tests' do + let(:group) do + RSpec.describe do + shared_examples 'passing tests' do + example 'not in quarantine' do + end + example 'in quarantine', :quarantine do + end + end + + context 'foo', :foo do + it_behaves_like 'passing tests' + end + + context 'default' do + it_behaves_like 'passing tests' + end + end + end + + context 'default config' do + it 'tests are skipped if in quarantine' do + group.run + + foo_context = group.children.find { |c| c.description == "foo" } + foo_examples = foo_context.descendant_filtered_examples + expect(foo_examples.count).to eq(2) + + ex = foo_examples.find { |e| e.description == "not in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + + ex = foo_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('In quarantine') + + default_context = group.children.find { |c| c.description == "default" } + default_examples = default_context.descendant_filtered_examples + expect(default_examples.count).to eq(2) + + ex = default_examples.find { |e| e.description == "not in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + + ex = default_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('In quarantine') + end + end + + context "with 'quarantine' tagged" do + before do + RSpec.configure do |config| + config.inclusion_filter = :quarantine + end + end + after do + RSpec.configure do |config| + config.inclusion_filter.clear + end + end + + it "only quarantined tests are run" do + group.run + + foo_context = group.children.find { |c| c.description == "foo" } + foo_examples = foo_context.descendant_filtered_examples + expect(foo_examples.count).to be(1) + + ex = foo_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + + default_context = group.children.find { |c| c.description == "default" } + default_examples = default_context.descendant_filtered_examples + expect(default_examples.count).to be(1) + + ex = default_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + end + end + + context "with 'foo' tagged" do + before do + RSpec.configure do |config| + config.inclusion_filter = :foo + end + + group.run + end + after do + RSpec.configure do |config| + config.inclusion_filter.clear + end + end + + it "tests are not run if not tagged 'foo'" do + default_context = group.children.find { |c| c.description == "default" } + expect(default_context.descendant_filtered_examples.count).to eq(0) + end + + it "tests are skipped if in quarantine" do + foo_context = group.children.find { |c| c.description == "foo" } + foo_examples = foo_context.descendant_filtered_examples + expect(foo_examples.count).to eq(2) + + ex = foo_examples.find { |e| e.description == "not in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + + ex = foo_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('In quarantine') + end + end + + context "with 'quarantine' and 'foo' tagged" do + before do + RSpec.configure do |config| + config.inclusion_filter = { quarantine: true, foo: true } + end + end + after do + RSpec.configure do |config| + config.inclusion_filter.clear + end + end + + it 'of tests tagged foo, only tests in quarantine run' do + group.run + + foo_context = group.children.find { |c| c.description == "foo" } + foo_examples = foo_context.descendant_filtered_examples + expect(foo_examples.count).to eq(2) + + ex = foo_examples.find { |e| e.description == "not in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:quarantine, :foo]') + + ex = foo_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:passed) + end + + it 'if tests are not tagged they are skipped, even if they are in quarantine' do + group.run + default_context = group.children.find { |c| c.description == "default" } + default_examples = default_context.descendant_filtered_examples + expect(default_examples.count).to eq(1) + + ex = default_examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('Running tests tagged with all of [:quarantine, :foo]') + end + end + + context "with 'foo' and 'bar' tagged" do + before do + RSpec.configure do |config| + config.inclusion_filter = { bar: true, foo: true } + end + end + after do + RSpec.configure do |config| + config.inclusion_filter.clear + end + end + + it "runs tests tagged either 'foo' or 'bar'" do + group = RSpec.describe do + example 'foo', :foo do + end + example 'bar', :bar do + end + example 'foo and bar', :foo, :bar do + end + end + + group.run + expect(group.examples.count).to eq(3) + + ex = group.examples.find { |e| e.description == "foo" } + expect(ex.execution_result.status).to eq(:passed) + + ex = group.examples.find { |e| e.description == "bar" } + expect(ex.execution_result.status).to eq(:passed) + + ex = group.examples.find { |e| e.description == "foo and bar" } + expect(ex.execution_result.status).to eq(:passed) + end + + it "skips quarantined tests tagged 'foo' and/or 'bar'" do + group = RSpec.describe do + example 'foo in quarantine', :foo, :quarantine do + end + example 'foo and bar in quarantine', :foo, :bar, :quarantine do + end + end + + group.run + expect(group.examples.count).to eq(2) + + ex = group.examples.find { |e| e.description == "foo in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('In quarantine') + + ex = group.examples.find { |e| e.description == "foo and bar in quarantine" } + expect(ex.execution_result.status).to eq(:pending) + expect(ex.execution_result.pending_message).to eq('In quarantine') + end + + it "ignores quarantined tests not tagged either 'foo' or 'bar'" do + group = RSpec.describe do + example 'in quarantine', :quarantine do + end + end + + group.run + + ex = group.examples.find { |e| e.description == "in quarantine" } + expect(ex.execution_result.status).to be_nil + end + end + + context "with 'foo' and 'bar' and 'quarantined' tagged" do + before do + RSpec.configure do |config| + config.inclusion_filter = { bar: true, foo: true, quarantine: true } + end + end + after do + RSpec.configure do |config| + config.inclusion_filter.clear + end + end + + it "runs tests tagged 'quarantine' and 'foo' or 'bar'" do + group = RSpec.describe do + example 'foo', :foo do + end + example 'bar and quarantine', :bar, :quarantine do + end + example 'foo and bar', :foo, :bar do + end + example 'foo, bar, and quarantine', :foo, :bar, :quarantine do + end + end + + group.run + expect(group.examples.count).to eq(4) + + ex = group.examples.find { |e| e.description == "foo" } + expect(ex.execution_result.status).to eq(:pending) + 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" } + expect(ex.execution_result.status).to eq(:passed) + + ex = group.examples.find { |e| e.description == "foo and bar" } + expect(ex.execution_result.status).to eq(:pending) + 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" } + expect(ex.execution_result.status).to eq(:passed) + end + end +end |