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
8da2ff21
Commit
8da2ff21
authored
Sep 23, 2019
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved specs based on review feedback
parent
f6b10751
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb
spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb
+8
-7
spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb
spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb
+6
-5
spec/support/shared_examples/lib/gitlab/ci/build/rules/rule/clause/clause_shared_examples.rb
...tlab/ci/build/rules/rule/clause/clause_shared_examples.rb
+12
-12
No files found.
spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb
View file @
8da2ff21
...
...
@@ -3,14 +3,15 @@
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Rules
::
Rule
::
Clause
::
Changes
do
describe
'satisfied_by?'
do
let
(
:pipeline
)
{
build
(
:ci_pipeline
)
}
subject
{
described_class
.
new
(
globs
)
}
describe
'
#
satisfied_by?'
do
it_behaves_like
'a glob matching rule'
do
let
(
:pipeline
)
{
build
(
:ci_pipeline
)
}
before
do
allow
(
pipeline
).
to
receive
(
:modified_paths
).
and_return
(
files
.
keys
)
end
before
do
allow
(
pipeline
).
to
receive
(
:modified_paths
).
and_return
(
files
.
keys
)
end
it_behaves_like
'a glob matching rule'
subject
{
described_class
.
new
(
globs
).
satisfied_by?
(
pipeline
,
nil
)
}
end
end
end
spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb
View file @
8da2ff21
...
...
@@ -3,11 +3,12 @@
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Rules
::
Rule
::
Clause
::
Exists
do
describe
'satisfied_by?'
do
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
files
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
project:
project
,
sha:
project
.
repository
.
head_commit
.
sha
)
}
subject
{
described_class
.
new
(
globs
)
}
describe
'
#
satisfied_by?'
do
it_behaves_like
'a glob matching rule'
do
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
files
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
project:
project
,
sha:
project
.
repository
.
head_commit
.
sha
)
}
it_behaves_like
'a glob matching rule'
subject
{
described_class
.
new
(
globs
).
satisfied_by?
(
pipeline
,
nil
)
}
end
end
end
spec/support/shared_examples/lib/gitlab/ci/build/rules/rule/clause/clause_shared_examples.rb
View file @
8da2ff21
...
...
@@ -4,20 +4,20 @@ RSpec.shared_examples 'a glob matching rule' do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:case_name
,
:globs
,
:files
,
:satisfied
)
do
'exact top-level match'
|
[
'Dockerfile'
]
|
{
'Dockerfile'
=>
''
,
'Gemfile'
=>
''
}
|
true
'exact top-level no match'
|
[
'Dockerfile'
]
|
{
'Gemfile'
=>
''
}
|
false
'pattern top-level match'
|
[
'Docker*'
]
|
{
'Dockerfile'
=>
''
,
'Gemfile'
=>
''
}
|
true
'pattern top-level no match'
|
[
'Docker*'
]
|
{
'Gemfile'
=>
''
}
|
false
'exact nested match'
|
[
'project/build.properties'
]
|
{
'project/build.properties'
=>
''
}
|
true
'exact nested no match'
|
[
'project/build.properties'
]
|
{
'project/README.md'
=>
''
}
|
false
'pattern nested match'
|
[
'src/**/*.go'
]
|
{
'src/gitlab.com/goproject/goproject.go'
=>
''
}
|
true
'pattern nested no match'
|
[
'src/**/*.go'
]
|
{
'src/gitlab.com/goproject/README.md'
=>
''
}
|
false
'leading slash no match'
|
[
'/*.go'
]
|
{
'main.go'
=>
''
}
|
false
'exact top-level match'
|
[
'Dockerfile'
]
|
{
'Dockerfile'
=>
''
,
'Gemfile'
=>
''
}
|
true
'exact top-level no match'
|
[
'Dockerfile'
]
|
{
'Gemfile'
=>
''
}
|
false
'pattern top-level match'
|
[
'Docker*'
]
|
{
'Dockerfile'
=>
''
,
'Gemfile'
=>
''
}
|
true
'pattern top-level no match'
|
[
'Docker*'
]
|
{
'Gemfile'
=>
''
}
|
false
'exact nested match'
|
[
'project/build.properties'
]
|
{
'project/build.properties'
=>
''
}
|
true
'exact nested no match'
|
[
'project/build.properties'
]
|
{
'project/README.md'
=>
''
}
|
false
'pattern nested match'
|
[
'src/**/*.go'
]
|
{
'src/gitlab.com/goproject/goproject.go'
=>
''
}
|
true
'pattern nested no match'
|
[
'src/**/*.go'
]
|
{
'src/gitlab.com/goproject/README.md'
=>
''
}
|
false
'ext top-level match'
|
[
'*.go'
]
|
{
'main.go'
=>
''
,
'cmd/goproject/main.go'
=>
''
}
|
true
'ext nested no match'
|
[
'*.go'
]
|
{
'cmd/goproject/main.go'
=>
''
}
|
false
'ext slash no match'
|
[
'/*.go'
]
|
{
'main.go'
=>
''
,
'cmd/goproject/main.go'
=>
''
}
|
false
end
with_them
do
it
'checks if any files exist'
do
expect
(
subject
.
satisfied_by?
(
pipeline
,
nil
)).
to
eq
(
satisfied
)
end
it
{
is_expected
.
to
eq
(
satisfied
)
}
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