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
87346078
Commit
87346078
authored
Aug 25, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for a simplifiable CI/CD entry aspect
parent
fcb4d1f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
spec/lib/gitlab/ci/config/entry/simplifiable_spec.rb
spec/lib/gitlab/ci/config/entry/simplifiable_spec.rb
+75
-0
No files found.
spec/lib/gitlab/ci/config/entry/simplifiable_spec.rb
0 → 100644
View file @
87346078
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Simplifiable
do
describe
'.strategy'
do
let
(
:entry
)
do
Class
.
new
(
described_class
)
do
strategy
:Something
,
if:
->
{
'condition'
}
strategy
:DifferentOne
,
if:
->
{
'condition'
}
end
end
it
'defines entry strategies'
do
expect
(
entry
.
strategies
.
size
).
to
eq
2
expect
(
entry
.
strategies
.
map
(
&
:name
))
.
to
eq
%i[Something DifferentOne]
end
end
describe
'setting strategy by a condition'
do
let
(
:first
)
{
double
(
'first strategy'
)
}
let
(
:second
)
{
double
(
'second strategy'
)
}
let
(
:unknown
)
{
double
(
'unknown strategy'
)
}
before
do
stub_const
(
"
#{
described_class
.
name
}
::Something"
,
first
)
stub_const
(
"
#{
described_class
.
name
}
::DifferentOne"
,
second
)
stub_const
(
"
#{
described_class
.
name
}
::UnknownStrategy"
,
unknown
)
end
context
'when first strategy should be used'
do
let
(
:entry
)
do
Class
.
new
(
described_class
)
do
strategy
:Something
,
if:
->
(
arg
)
{
arg
==
'something'
}
strategy
:DifferentOne
,
if:
->
(
*
)
{
false
}
end
end
it
'attemps to load a first strategy'
do
expect
(
first
).
to
receive
(
:new
).
with
(
'something'
,
anything
)
entry
.
new
(
'something'
)
end
end
context
'when second strategy should be used'
do
let
(
:entry
)
do
Class
.
new
(
described_class
)
do
strategy
:Something
,
if:
->
(
arg
)
{
arg
==
'something'
}
strategy
:DifferentOne
,
if:
->
(
arg
)
{
arg
==
'test'
}
end
end
it
'attemps to load a second strategy'
do
expect
(
second
).
to
receive
(
:new
).
with
(
'test'
,
anything
)
entry
.
new
(
'test'
)
end
end
context
'when neither one is a valid strategy'
do
let
(
:entry
)
do
Class
.
new
(
described_class
)
do
strategy
:Something
,
if:
->
(
*
)
{
false
}
strategy
:DifferentOne
,
if:
->
(
*
)
{
false
}
end
end
it
'instantiates an unknown strategy'
do
expect
(
unknown
).
to
receive
(
:new
).
with
(
'test'
,
anything
)
entry
.
new
(
'test'
)
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