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
b85b6590
Commit
b85b6590
authored
Feb 20, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and document an RSpec::Parameterized::TableSyntax edge-case
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
e0fc809b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+5
-5
spec/models/prometheus_metric_spec.rb
spec/models/prometheus_metric_spec.rb
+6
-7
No files found.
doc/development/testing_guide/best_practices.md
View file @
b85b6590
...
...
@@ -358,16 +358,11 @@ range of inputs, might look like this:
describe
"#=="
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:project1
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
where
(
:a
,
:b
,
:result
)
do
1
|
1
|
true
1
|
2
|
false
true
|
true
|
true
true
|
false
|
false
project1
|
project1
|
true
project2
|
project2
|
true
project
1
|
project2
|
false
end
with_them
do
...
...
@@ -380,6 +375,11 @@ describe "#==" do
end
```
CAUTION:
**Caution:**
Only use simple values as input in the
`where`
block. Using procs, stateful
objects, FactoryBot-created objects etc. can lead to
[
unexpected results
](
https://github.com/tomykaira/rspec-parameterized/issues/8
)
.
### Prometheus tests
Prometheus metrics may be preserved from one test run to another. To ensure that metrics are
...
...
spec/models/prometheus_metric_spec.rb
View file @
b85b6590
...
...
@@ -4,7 +4,6 @@ require 'spec_helper'
describe
PrometheusMetric
do
subject
{
build
(
:prometheus_metric
)
}
let
(
:other_project
)
{
build
(
:project
)
}
it_behaves_like
'having unique enum values'
...
...
@@ -16,17 +15,17 @@ describe PrometheusMetric do
describe
'common metrics'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:common
,
:project
,
:result
)
do
false
|
other_project
|
true
false
|
nil
|
false
true
|
other_project
|
false
true
|
nil
|
true
where
(
:common
,
:
with_
project
,
:result
)
do
false
|
true
|
true
false
|
false
|
false
true
|
true
|
false
true
|
false
|
true
end
with_them
do
before
do
subject
.
common
=
common
subject
.
project
=
project
subject
.
project
=
with_project
?
build
(
:project
)
:
nil
end
it
{
expect
(
subject
.
valid?
).
to
eq
(
result
)
}
...
...
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