diff --git a/qa/qa/page/main/entry.rb b/qa/qa/page/main/entry.rb index a9810beeb296f19b60bc9bab8bf6ac563c2f190d..fa1cad62741ddd9f42f2ca2157c80e0db0a33967 100644 --- a/qa/qa/page/main/entry.rb +++ b/qa/qa/page/main/entry.rb @@ -3,7 +3,7 @@ module QA module Main class Entry < Page::Base def initialize - visit('/') + visit(Runtime::Scenario.gitlab_address) # This resolves cold boot / background tasks problems # diff --git a/qa/qa/scenario/entrypoint.rb b/qa/qa/scenario/entrypoint.rb index 8f708fe38ab1d97628f3725259f758fcbc91e0f7..ae099fd911e5417409bbf3719eabfdecfe9db867 100644 --- a/qa/qa/scenario/entrypoint.rb +++ b/qa/qa/scenario/entrypoint.rb @@ -7,18 +7,8 @@ module QA class Entrypoint < Template include Bootable - def self.tags(*tags) - @tags = tags - end - - def self.get_tags - @tags - end - def perform(address, *files) - Specs::Config.perform do |specs| - specs.address = address - end + Runtime::Scenario.define(:gitlab_address, address) ## # Perform before hooks, which are different for CE and EE @@ -26,13 +16,19 @@ module QA Runtime::Release.perform_before_hooks Specs::Runner.perform do |specs| - specs.rspec( - tty: true, - tags: self.class.get_tags, - files: files.any? ? files : 'qa/specs/features' - ) + specs.tty = true + specs.tags = self.class.get_tags + specs.files = files.any? ? files : 'qa/specs/features' end end + + def self.tags(*tags) + @tags = tags + end + + def self.get_tags + @tags + end end end end diff --git a/qa/qa/specs/config.rb b/qa/qa/specs/config.rb index 79c681168cceea5e2ebc376f61dfb45a57e534c3..591ddde8ab9e0061640020645e43ab0ff17ba4f1 100644 --- a/qa/qa/specs/config.rb +++ b/qa/qa/specs/config.rb @@ -9,15 +9,7 @@ require 'selenium-webdriver' module QA module Specs class Config < Scenario::Template - attr_writer :address - - def initialize - @address = ENV['GITLAB_URL'] - end - def perform - raise 'Please configure GitLab address!' unless @address - configure_rspec! configure_capybara! end @@ -56,7 +48,6 @@ module QA end Capybara.configure do |config| - config.app_host = @address config.default_driver = :chrome config.javascript_driver = :chrome config.default_max_wait_time = 4 diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb index 2aa18d5d3a10fcd1c4d1d7162aa0bd474ef6c637..f98b8f88e9ae018ae0813b8dbb79f51203c8246d 100644 --- a/qa/qa/specs/runner.rb +++ b/qa/qa/specs/runner.rb @@ -2,16 +2,22 @@ require 'rspec/core' module QA module Specs - class Runner - include Scenario::Actable + class Runner < Scenario::Template + attr_accessor :tty, :tags, :files - def rspec(tty: false, tags: [], files: ['qa/specs/features']) + def initialize + @tty = false + @tags = [] + @files = ['qa/specs/features'] + end + + def perform args = [] - args << '--tty' if tty - tags.to_a.each do |tag| - args << ['-t', tag.to_s] - end - args << files + args.push('--tty') if tty + tags.to_a.each { |tag| args.push(['-t', tag.to_s]) } + args.push(files) + + Specs::Config.perform RSpec::Core::Runner.run(args.flatten, $stderr, $stdout).tap do |status| abort if status.nonzero? diff --git a/qa/spec/scenario/entrypoint_spec.rb b/qa/spec/scenario/entrypoint_spec.rb index 3fd068b641c9f4934686a2684bac3dff63300f19..aec79dcea04ce32429e15701fe4df9c5080c2dce 100644 --- a/qa/spec/scenario/entrypoint_spec.rb +++ b/qa/spec/scenario/entrypoint_spec.rb @@ -6,31 +6,30 @@ describe QA::Scenario::Entrypoint do end context '#perform' do - let(:config) { spy('Specs::Config') } + let(:arguments) { spy('Runtime::Scenario') } let(:release) { spy('Runtime::Release') } let(:runner) { spy('Specs::Runner') } before do - allow(config).to receive(:perform) { |&block| block.call config } - allow(runner).to receive(:perform) { |&block| block.call runner } - - stub_const('QA::Specs::Config', config) stub_const('QA::Runtime::Release', release) + stub_const('QA::Runtime::Scenario', arguments) stub_const('QA::Specs::Runner', runner) + + allow(runner).to receive(:perform).and_yield(runner) end - it 'should set address' do + it 'sets an address of the subject' do subject.perform("hello") - expect(config).to have_received(:address=).with("hello") + expect(arguments).to have_received(:define) + .with(:gitlab_address, "hello") end context 'no paths' do it 'should call runner with default arguments' do subject.perform("test") - expect(runner).to have_received(:rspec) - .with(hash_including(files: 'qa/specs/features')) + expect(runner).to have_received(:files=).with('qa/specs/features') end end @@ -38,8 +37,7 @@ describe QA::Scenario::Entrypoint do it 'should call runner with paths' do subject.perform('test', 'path1', 'path2') - expect(runner).to have_received(:rspec) - .with(hash_including(files: %w(path1 path2))) + expect(runner).to have_received(:files=).with(%w[path1 path2]) end end end