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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
1011ca49
Commit
1011ca49
authored
Jan 11, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a DSL evaluator to QA base factory class
parent
2de8fb7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
qa/qa/factory/base.rb
qa/qa/factory/base.rb
+22
-7
No files found.
qa/qa/factory/base.rb
View file @
1011ca49
require
'forwardable'
module
QA
module
QA
module
Factory
module
Factory
class
Base
class
Base
extend
SingleForwardable
def_delegators
:evaluator
,
:dependency
,
:dependencies
def
fabricate!
(
*
_args
)
def
fabricate!
(
*
_args
)
raise
NotImplementedError
raise
NotImplementedError
end
end
...
@@ -17,16 +23,25 @@ module QA
...
@@ -17,16 +23,25 @@ module QA
end
end
end
end
def
self
.
dependencies
def
self
.
evaluator
@
dependencies
||=
{}
@
evaluator
||=
Factory
::
Base
::
DSL
.
new
(
self
)
end
end
def
self
.
dependency
(
factory
,
as
:,
&
block
)
class
DSL
as
.
tap
do
|
name
|
attr_reader
:dependencies
class_eval
{
attr_accessor
name
}
def
initialize
(
base
)
@base
=
base
@dependencies
=
{}
end
def
dependency
(
factory
,
as
:,
&
block
)
as
.
tap
do
|
name
|
@base
.
class_eval
{
attr_accessor
name
}
Dependency
::
Signature
.
new
(
factory
,
block
).
tap
do
|
signature
|
Dependency
::
Signature
.
new
(
factory
,
block
).
tap
do
|
signature
|
dependencies
.
store
(
name
,
signature
)
dependencies
.
store
(
name
,
signature
)
end
end
end
end
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