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
d32a1517
Commit
d32a1517
authored
Jan 11, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to define QA factory product attributes
parent
1011ca49
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
qa/qa/factory/base.rb
qa/qa/factory/base.rb
+10
-2
qa/qa/factory/product.rb
qa/qa/factory/product.rb
+2
-0
qa/spec/factory/base_spec.rb
qa/spec/factory/base_spec.rb
+30
-16
No files found.
qa/qa/factory/base.rb
View file @
d32a1517
...
...
@@ -6,6 +6,7 @@ module QA
extend
SingleForwardable
def_delegators
:evaluator
,
:dependency
,
:dependencies
def_delegators
:evaluator
,
:product
,
:attributes
def
fabricate!
(
*
_args
)
raise
NotImplementedError
...
...
@@ -28,11 +29,12 @@ module QA
end
class
DSL
attr_reader
:dependencies
attr_reader
:dependencies
,
:attributes
def
initialize
(
base
)
@base
=
base
@dependencies
=
{}
@attributes
=
{}
end
def
dependency
(
factory
,
as
:,
&
block
)
...
...
@@ -40,10 +42,16 @@ module QA
@base
.
class_eval
{
attr_accessor
name
}
Dependency
::
Signature
.
new
(
factory
,
block
).
tap
do
|
signature
|
dependencies
.
store
(
name
,
signature
)
@
dependencies
.
store
(
name
,
signature
)
end
end
end
def
product
(
attribute
,
&
block
)
Product
::
Attribute
.
new
(
attribute
,
block
).
tap
do
|
signature
|
@attributes
.
store
(
attribute
,
signature
)
end
end
end
end
end
...
...
qa/qa/factory/product.rb
View file @
d32a1517
...
...
@@ -5,6 +5,8 @@ module QA
class
Product
include
Capybara
::
DSL
Attribute
=
Struct
.
new
(
:name
,
:block
)
def
initialize
(
factory
)
@factory
=
factory
@location
=
current_url
...
...
qa/spec/factory/base_spec.rb
View file @
d32a1517
...
...
@@ -59,9 +59,8 @@ describe QA::Factory::Base do
it
'defines dependency accessors'
do
expect
(
subject
.
new
).
to
respond_to
:mydep
,
:mydep
=
end
end
describe
'building dependencies
'
do
describe
'dependencies fabrication
'
do
let
(
:dependency
)
{
double
(
'dependency'
)
}
let
(
:instance
)
{
spy
(
'instance'
)
}
...
...
@@ -85,4 +84,19 @@ describe QA::Factory::Base do
subject
.
fabricate!
end
end
end
describe
'.product'
do
subject
do
Class
.
new
(
described_class
)
do
product
:token
do
|
factory
,
page
|
page
.
do_something!
end
end
end
it
'appends new product attribute'
do
expect
(
subject
.
attributes
).
to
be_one
end
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