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
f8bec0d1
Commit
f8bec0d1
authored
Dec 06, 2016
by
Leandro Camargo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve specs styles/organization and add some more specs
parent
6323cd72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
20 deletions
+38
-20
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/coverage_spec.rb
spec/lib/gitlab/ci/config/entry/coverage_spec.rb
+22
-3
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+8
-10
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+7
-6
No files found.
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
f8bec0d1
...
@@ -20,7 +20,7 @@ module Ci
...
@@ -20,7 +20,7 @@ module Ci
it
{
is_expected
.
to
include
(
coverage_regex:
'\(\d+\.\d+\) covered'
)
}
it
{
is_expected
.
to
include
(
coverage_regex:
'\(\d+\.\d+\) covered'
)
}
end
end
context
'but \'rspec\' job also has coverage set'
do
context
"but 'rspec' job also has coverage set"
do
before
do
before
do
config_base
[
:rspec
][
:coverage
]
=
'/Code coverage: \d+\.\d+/'
config_base
[
:rspec
][
:coverage
]
=
'/Code coverage: \d+\.\d+/'
end
end
...
...
spec/lib/gitlab/ci/config/entry/coverage_spec.rb
View file @
f8bec0d1
...
@@ -4,12 +4,31 @@ describe Gitlab::Ci::Config::Entry::Coverage do
...
@@ -4,12 +4,31 @@ describe Gitlab::Ci::Config::Entry::Coverage do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
describe
'validations'
do
context
'when entry config value is correct'
do
context
"when entry config value is correct without surrounding '/'"
do
let
(
:config
)
{
'Code coverage: \d+\.\d+'
}
let
(
:config
)
{
'Code coverage: \d+\.\d+'
}
describe
'#value'
do
describe
'#value'
do
subject
{
entry
.
value
}
subject
{
entry
.
value
}
it
{
is_expected
.
to
eq
config
}
it
{
is_expected
.
to
eq
(
config
)
}
end
describe
'#errors'
do
subject
{
entry
.
errors
}
it
{
is_expected
.
to
be_empty
}
end
describe
'#valid?'
do
subject
{
entry
}
it
{
is_expected
.
to
be_valid
}
end
end
context
"when entry config value is correct with surrounding '/'"
do
let
(
:config
)
{
'/Code coverage: \d+\.\d+/'
}
describe
'#value'
do
subject
{
entry
.
value
}
it
{
is_expected
.
to
eq
(
config
[
1
...-
1
])
}
end
end
describe
'#errors'
do
describe
'#errors'
do
...
@@ -28,7 +47,7 @@ describe Gitlab::Ci::Config::Entry::Coverage do
...
@@ -28,7 +47,7 @@ describe Gitlab::Ci::Config::Entry::Coverage do
describe
'#errors'
do
describe
'#errors'
do
subject
{
entry
.
errors
}
subject
{
entry
.
errors
}
it
{
is_expected
.
to
include
/coverage config must be a regular expression/
}
it
{
is_expected
.
to
include
(
/coverage config must be a regular expression/
)
}
end
end
describe
'#valid?'
do
describe
'#valid?'
do
...
...
spec/lib/gitlab/ci/config/entry/global_spec.rb
View file @
f8bec0d1
...
@@ -4,19 +4,17 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -4,19 +4,17 @@ describe Gitlab::Ci::Config::Entry::Global do
let
(
:global
)
{
described_class
.
new
(
hash
)
}
let
(
:global
)
{
described_class
.
new
(
hash
)
}
describe
'.nodes'
do
describe
'.nodes'
do
subject
{
described_class
.
nodes
}
it
'returns a hash'
do
expect
(
described_class
.
nodes
).
to
be_a
(
Hash
)
it
{
is_expected
.
to
be_a
Hash
}
end
context
'when filtering all the entry/node names'
do
context
'when filtering all the entry/node names'
do
subject
{
described_class
.
nodes
.
keys
}
it
'contains the expected node names'
do
node_names
=
described_class
.
nodes
.
keys
let
(
:result
)
do
expect
(
node_names
).
to
match_array
(
%i[before_script image services
%i[before_script image services after_script variables stages typ
es
after_script variables stag
es
cache coverage]
types cache coverage]
)
end
end
it
{
is_expected
.
to
match_array
result
}
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
f8bec0d1
...
@@ -251,12 +251,13 @@ describe Ci::Build, :models do
...
@@ -251,12 +251,13 @@ describe Ci::Build, :models do
end
end
describe
'#update_coverage'
do
describe
'#update_coverage'
do
it
'grants coverage_regex method is called inside of it'
do
context
"regarding coverage_regex's value,"
do
build
.
coverage_regex
=
'\(\d+.\d+\%\) covered'
it
"saves the correct extracted coverage value"
do
allow
(
build
).
to
receive
(
:trace
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered'
}
build
.
coverage_regex
=
'\(\d+.\d+\%\) covered'
allow
(
build
).
to
receive
(
:coverage_regex
).
and_call_original
allow
(
build
).
to
receive
(
:trace
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered'
}
expect
(
build
).
to
receive
(
:update_attributes
).
with
(
coverage:
98.29
)
{
true
}
expect
(
build
).
to
receive
(
:update_attributes
).
with
(
coverage:
98.29
)
{
true
}
expect
(
build
.
update_coverage
).
to
be
true
expect
(
build
.
update_coverage
).
to
be
true
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