提交 65faebb9 编写于 作者: R Rémy Coutable

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
......@@ -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
#
......
......@@ -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
......@@ -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
......
......@@ -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?
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册