Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
77103646
Commit
77103646
authored
Nov 09, 2017
by
Grzegorz Bizon
Committed by
Rémy Coutable
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to define global scenario attributes
parent
760b2c75
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
128 additions
and
5 deletions
+128
-5
qa/.gitignore
qa/.gitignore
+1
-0
qa/bin/qa
qa/bin/qa
+1
-1
qa/qa.rb
qa/qa.rb
+1
-0
qa/qa/page/mattermost/login.rb
qa/qa/page/mattermost/login.rb
+1
-1
qa/qa/page/mattermost/main.rb
qa/qa/page/mattermost/main.rb
+1
-1
qa/qa/runtime/scenario.rb
qa/qa/runtime/scenario.rb
+21
-1
qa/qa/scenario/bootable.rb
qa/qa/scenario/bootable.rb
+47
-0
qa/qa/scenario/entrypoint.rb
qa/qa/scenario/entrypoint.rb
+2
-0
qa/qa/scenario/test/integration/mattermost.rb
qa/qa/scenario/test/integration/mattermost.rb
+2
-1
qa/spec/runtime/scenario_spec.rb
qa/spec/runtime/scenario_spec.rb
+27
-0
qa/spec/scenario/bootable_spec.rb
qa/spec/scenario/bootable_spec.rb
+24
-0
No files found.
qa/.gitignore
View file @
77103646
tmp/
.ruby-version
qa/bin/qa
View file @
77103646
...
...
@@ -4,4 +4,4 @@ require_relative '../qa'
QA
::
Scenario
.
const_get
(
ARGV
.
shift
)
.
perform
(
*
ARGV
)
.
launch!
(
*
ARGV
)
qa/qa.rb
View file @
77103646
...
...
@@ -18,6 +18,7 @@ module QA
##
# Support files
#
autoload
:Bootable
,
'qa/scenario/bootable'
autoload
:Actable
,
'qa/scenario/actable'
autoload
:Entrypoint
,
'qa/scenario/entrypoint'
autoload
:Template
,
'qa/scenario/template'
...
...
qa/qa/page/mattermost/login.rb
View file @
77103646
...
...
@@ -3,7 +3,7 @@ module QA
module
Mattermost
class
Login
<
Page
::
Base
def
initialize
visit
(
Runtime
::
Scenario
.
mattermost
+
'/login'
)
visit
(
Runtime
::
Scenario
.
mattermost
_address
+
'/login'
)
end
def
sign_in_using_oauth
...
...
qa/qa/page/mattermost/main.rb
View file @
77103646
...
...
@@ -3,7 +3,7 @@ module QA
module
Mattermost
class
Main
<
Page
::
Base
def
initialize
visit
(
Runtime
::
Scenario
.
mattermost
)
visit
(
Runtime
::
Scenario
.
mattermost
_address
)
end
end
end
...
...
qa/qa/runtime/scenario.rb
View file @
77103646
module
QA
module
Runtime
##
# Singleton approach to global test scenario arguments.
#
module
Scenario
extend
self
attr_accessor
:mattermost
attr_reader
:attributes
def
define
(
attribute
,
value
)
(
@attributes
||=
{}).
store
(
attribute
.
to_sym
,
value
)
define_singleton_method
(
attribute
)
do
@attributes
[
attribute
.
to_sym
].
tap
do
|
value
|
if
value
.
to_s
.
empty?
raise
ArgumentError
,
"Empty `
#{
attribute
}
` attribute!"
end
end
end
end
def
method_missing
(
name
,
*
)
raise
ArgumentError
,
"Scenario attribute `
#{
name
}
` not defined!"
end
end
end
end
qa/qa/scenario/bootable.rb
0 → 100644
View file @
77103646
require
'optparse'
module
QA
module
Scenario
module
Bootable
Option
=
Struct
.
new
(
:name
,
:arg
,
:desc
)
def
self
.
included
(
base
)
base
.
extend
(
ClassMethods
)
end
module
ClassMethods
def
launch!
(
argv
)
arguments
=
OptionParser
.
new
do
|
parser
|
options
.
to_a
.
each
do
|
opt
|
parser
.
on
(
opt
.
arg
,
opt
.
desc
)
do
|
value
|
Runtime
::
Scenario
.
define
(
opt
.
name
,
value
)
end
end
end
arguments
.
parse!
(
argv
)
if
has_attributes?
self
.
perform
(
**
Runtime
::
Scenario
.
attributes
)
else
self
.
perform
(
*
argv
)
end
end
private
def
attribute
(
name
,
arg
,
desc
)
options
.
push
(
Option
.
new
(
name
,
arg
,
desc
))
end
def
options
@options
||=
[]
end
def
has_attributes?
options
.
any?
end
end
end
end
end
qa/qa/scenario/entrypoint.rb
View file @
77103646
...
...
@@ -5,6 +5,8 @@ module QA
# including staging and on-premises installation.
#
class
Entrypoint
<
Template
include
Bootable
def
self
.
tags
(
*
tags
)
@tags
=
tags
end
...
...
qa/qa/scenario/test/integration/mattermost.rb
View file @
77103646
...
...
@@ -10,7 +10,8 @@ module QA
tags
:core
,
:mattermost
def
perform
(
address
,
mattermost
,
*
files
)
Runtime
::
Scenario
.
mattermost
=
mattermost
Runtime
::
Scenario
.
define
(
:mattermost_address
,
mattermost
)
super
(
address
,
*
files
)
end
end
...
...
qa/spec/runtime/scenario_spec.rb
0 → 100644
View file @
77103646
describe
QA
::
Runtime
::
Scenario
do
subject
do
Module
.
new
.
extend
(
described_class
)
end
it
'makes it possible to define global scenario attributes'
do
subject
.
define
(
:my_attribute
,
'some-value'
)
subject
.
define
(
:another_attribute
,
'another-value'
)
expect
(
subject
.
my_attribute
).
to
eq
'some-value'
expect
(
subject
.
another_attribute
).
to
eq
'another-value'
expect
(
subject
.
attributes
)
.
to
eq
(
my_attribute:
'some-value'
,
another_attribute:
'another-value'
)
end
it
'raises error when attribute is not known'
do
expect
{
subject
.
invalid_accessor
}
.
to
raise_error
ArgumentError
,
/invalid_accessor/
end
it
'raises error when attribute is empty'
do
subject
.
define
(
:empty_attribute
,
''
)
expect
{
subject
.
empty_attribute
}
.
to
raise_error
ArgumentError
,
/empty_attribute/
end
end
qa/spec/scenario/bootable_spec.rb
0 → 100644
View file @
77103646
describe
QA
::
Scenario
::
Bootable
do
subject
do
Class
.
new
(
QA
::
Scenario
::
Template
)
.
include
(
described_class
)
end
it
'makes it possible to define the scenario attribute'
do
subject
.
class_eval
do
attribute
:something
,
'--something SOMETHING'
,
'Some attribute'
attribute
:another
,
'--another ANOTHER'
,
'Some other attribute'
end
expect
(
subject
).
to
receive
(
:perform
)
.
with
(
something:
'test'
,
another:
'other'
)
subject
.
launch!
(
%w[--another other --something test]
)
end
it
'does not require attributes to be defined'
do
expect
(
subject
).
to
receive
(
:perform
).
with
(
'some'
,
'argv'
)
subject
.
launch!
(
%w[some argv]
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment