Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5bef3219
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
5bef3219
编写于
4月 06, 2018
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce RspecFlaky::ExamplesPruner to prune old flaky examples
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
9d220da8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
0 deletion
+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
未找到文件。
lib/rspec_flaky/examples_pruner.rb
0 → 100644
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录