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
5bef3219
Commit
5bef3219
authored
Apr 06, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce RspecFlaky::ExamplesPruner to prune old flaky examples
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
9d220da8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
lib/rspec_flaky/examples_pruner.rb
lib/rspec_flaky/examples_pruner.rb
+25
-0
lib/rspec_flaky/flaky_examples_collection.rb
lib/rspec_flaky/flaky_examples_collection.rb
+2
-0
spec/lib/rspec_flaky/examples_pruner_spec.rb
spec/lib/rspec_flaky/examples_pruner_spec.rb
+33
-0
No files found.
lib/rspec_flaky/examples_pruner.rb
0 → 100644
View file @
5bef3219
require
'json'
module
RspecFlaky
class
ExamplesPruner
# - flaky_examples: contains flaky examples
attr_reader
:flaky_examples
def
initialize
(
collection
)
unless
collection
.
is_a?
(
RspecFlaky
::
FlakyExamplesCollection
)
raise
ArgumentError
,
"`collection` must be a RspecFlaky::FlakyExamplesCollection,
#{
collection
.
class
}
given!"
end
@flaky_examples
=
collection
end
def
prune_examples_older_than
(
date
)
updated_hash
=
flaky_examples
.
dup
.
delete_if
do
|
uid
,
hash
|
hash
[
:last_flaky_at
]
&&
Time
.
parse
(
hash
[
:last_flaky_at
]).
to_i
<
date
.
to_i
end
RspecFlaky
::
FlakyExamplesCollection
.
new
(
updated_hash
)
end
end
end
lib/rspec_flaky/flaky_examples_collection.rb
View file @
5bef3219
require
'json'
require_relative
'flaky_example'
module
RspecFlaky
class
FlakyExamplesCollection
<
SimpleDelegator
def
self
.
from_json
(
json
)
...
...
spec/lib/rspec_flaky/examples_pruner_spec.rb
0 → 100644
View file @
5bef3219
require
'spec_helper'
describe
RspecFlaky
::
ExamplesPruner
,
:aggregate_failures
do
let
(
:collection_hash
)
do
{
a:
{
example_id:
'spec/foo/bar_spec.rb:2'
},
b:
{
example_id:
'spec/foo/baz_spec.rb:3'
,
first_flaky_at:
Time
.
utc
(
2000
,
1
,
1
).
to_s
,
last_flaky_at:
Time
.
utc
(
2000
,
2
,
1
).
to_s
}
}
end
describe
'#initialize'
do
it
'accepts a collection'
do
expect
{
described_class
.
new
(
RspecFlaky
::
FlakyExamplesCollection
.
new
(
collection_hash
))
}.
not_to
raise_error
end
it
'does not accept anything else'
do
expect
{
described_class
.
new
([
1
,
2
,
3
])
}.
to
raise_error
(
ArgumentError
,
"`collection` must be a RspecFlaky::FlakyExamplesCollection, Array given!"
)
end
end
describe
'#prune_examples_older_than'
do
it
'returns a new collection without the examples older than 3 months'
do
collection
=
RspecFlaky
::
FlakyExamplesCollection
.
new
(
collection_hash
)
new_report
=
collection
.
to_report
.
dup
.
tap
{
|
r
|
r
.
delete
(
:b
)
}
new_collection
=
described_class
.
new
(
collection
).
prune_examples_older_than
(
3
.
months
.
ago
)
expect
(
new_collection
).
to
be_a
(
RspecFlaky
::
FlakyExamplesCollection
)
expect
(
new_collection
.
to_report
).
to
eq
(
new_report
)
expect
(
collection
).
to
have_key
(
:b
)
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