summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-10 12:50:49 +0000
committerRémy Coutable <remy@rymai.me>2017-11-10 12:50:49 +0000
commit65faebb95556809c5858347f1c24422505056827 (patch)
tree758405d95ceb48279bc51289fcd255ee22bf5e6b
parent58dd9d73ab51c74bca354ae632b252db8def4e41 (diff)
parent2c468dfdafbeded7c8d5f2dc70e09d3595efa542 (diff)
downloadgitlab-ce-65faebb95556809c5858347f1c24422505056827.tar.gz
Merge branch 'qa/gb/rspec-decouple-test-instance-address' into 'master'
Decouple QA test subject's address from Capybara/RSpec Closes gitlab-qa#88 See merge request gitlab-org/gitlab-ce!15310
-rw-r--r--qa/qa/page/main/entry.rb2
-rw-r--r--qa/qa/scenario/entrypoint.rb28
-rw-r--r--qa/qa/specs/config.rb9
-rw-r--r--qa/qa/specs/runner.rb22
-rw-r--r--qa/spec/scenario/entrypoint_spec.rb20
5 files changed, 36 insertions, 45 deletions
diff --git a/qa/qa/page/main/entry.rb b/qa/qa/page/main/entry.rb
index a9810beeb29..fa1cad62741 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 8f708fe38ab..ae099fd911e 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 79c681168cc..591ddde8ab9 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 2aa18d5d3a1..f98b8f88e9a 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 3fd068b641c..aec79dcea04 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