Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
76f22e19
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
76f22e19
编写于
7月 22, 2018
作者:
K
Kasper Timm Hansen
提交者:
GitHub
7月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33403 from bogdanvlviv/clarify-test_notes_finds_notes_in_custom_directories
Clarify `railties/test/application/rake/notes_test.rb`
上级
9ca579ad
a6ebafc5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
59 deletion
+58
-59
railties/test/application/rake/notes_test.rb
railties/test/application/rake/notes_test.rb
+58
-59
未找到文件。
railties/test/application/rake/notes_test.rb
浏览文件 @
76f22e19
...
...
@@ -30,19 +30,22 @@ def teardown
app_file
"config/locales/en.yaml"
,
"# TODO: note in yaml"
app_file
"app/views/home/index.ruby"
,
"# TODO: note in ruby"
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in erb/
,
output
)
assert_match
(
/note in js/
,
output
)
assert_match
(
/note in css/
,
output
)
assert_match
(
/note in rake/
,
output
)
assert_match
(
/note in builder/
,
output
)
assert_match
(
/note in yml/
,
output
)
assert_match
(
/note in yaml/
,
output
)
assert_match
(
/note in ruby/
,
output
)
assert_equal
9
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
stderr
=
capture
(
:stderr
)
do
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in erb/
,
output
)
assert_match
(
/note in js/
,
output
)
assert_match
(
/note in css/
,
output
)
assert_match
(
/note in rake/
,
output
)
assert_match
(
/note in builder/
,
output
)
assert_match
(
/note in yml/
,
output
)
assert_match
(
/note in yaml/
,
output
)
assert_match
(
/note in ruby/
,
output
)
assert_equal
9
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
end
end
assert_match
(
/DEPRECATION WARNING: This rake task is deprecated and will be removed in Rails 6.1/
,
stderr
)
end
test
"notes finds notes in default directories"
do
...
...
@@ -54,17 +57,20 @@ def teardown
app_file
"some_other_dir/blah.rb"
,
"# TODO: note in some_other directory"
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in app directory/
,
output
)
assert_match
(
/note in config directory/
,
output
)
assert_match
(
/note in db directory/
,
output
)
assert_match
(
/note in lib directory/
,
output
)
assert_match
(
/note in test directory/
,
output
)
assert_no_match
(
/note in some_other directory/
,
output
)
assert_equal
5
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
stderr
=
capture
(
:stderr
)
do
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in app directory/
,
output
)
assert_match
(
/note in config directory/
,
output
)
assert_match
(
/note in db directory/
,
output
)
assert_match
(
/note in lib directory/
,
output
)
assert_match
(
/note in test directory/
,
output
)
assert_no_match
(
/note in some_other directory/
,
output
)
assert_equal
5
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
end
end
assert_match
(
/DEPRECATION WARNING: This rake task is deprecated and will be removed in Rails 6.1/
,
stderr
)
end
test
"notes finds notes in custom directories"
do
...
...
@@ -76,21 +82,22 @@ def teardown
app_file
"some_other_dir/blah.rb"
,
"# TODO: note in some_other directory"
run_rake_notes
"SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bin/rails notes"
do
|
output
,
lines
|
assert_match
(
/note in app directory/
,
output
)
assert_match
(
/note in config directory/
,
output
)
assert_match
(
/note in db directory/
,
output
)
assert_match
(
/note in lib directory/
,
output
)
assert_match
(
/note in test directory/
,
output
)
stderr
=
capture
(
:stderr
)
do
run_rake_notes
"SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bin/rake notes"
do
|
output
,
lines
|
assert_match
(
/note in app directory/
,
output
)
assert_match
(
/note in config directory/
,
output
)
assert_match
(
/note in db directory/
,
output
)
assert_match
(
/note in lib directory/
,
output
)
assert_match
(
/note in test directory/
,
output
)
assert_match
(
/note in some_other directory/
,
output
)
assert_match
(
/note in some_other directory/
,
output
)
assert_equal
6
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
log
=
File
.
read
(
Rails
.
application
.
config
.
paths
[
"log"
].
first
)
assert_match
(
/`SOURCE_ANNOTATION_DIRECTORIES` is deprecated/
,
log
)
assert_equal
6
,
lines
.
size
assert_equal
[
4
],
lines
.
map
(
&
:size
).
uniq
end
end
assert_match
(
/DEPRECATION WARNING: This rake task is deprecated and will be removed in Rails 6.1/
,
stderr
)
assert_match
(
/DEPRECATION WARNING: `SOURCE_ANNOTATION_DIRECTORIES` is deprecated and will be removed in Rails 6.1/
,
stderr
)
end
test
"custom rake task finds specific notes in specific directories"
do
...
...
@@ -125,11 +132,14 @@ def teardown
app_file
"app/assets/stylesheets/application.css.scss"
,
"// TODO: note in scss"
app_file
"app/assets/stylesheets/application.css.sass"
,
"// TODO: note in sass"
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in scss/
,
output
)
assert_match
(
/note in sass/
,
output
)
assert_equal
2
,
lines
.
size
stderr
=
capture
(
:stderr
)
do
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in scss/
,
output
)
assert_match
(
/note in sass/
,
output
)
assert_equal
2
,
lines
.
size
end
end
assert_match
(
/DEPRECATION WARNING: This rake task is deprecated and will be removed in Rails 6.1/
,
stderr
)
end
test
"register additional directories"
do
...
...
@@ -137,38 +147,27 @@ def teardown
app_file
"spec/models/user_spec.rb"
,
"# TODO: note in model spec"
add_to_config
' config.annotations.register_directories("spec") '
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in spec/
,
output
)
assert_match
(
/note in model spec/
,
output
)
assert_equal
2
,
lines
.
size
stderr
=
capture
(
:stderr
)
do
run_rake_notes
do
|
output
,
lines
|
assert_match
(
/note in spec/
,
output
)
assert_match
(
/note in model spec/
,
output
)
assert_equal
2
,
lines
.
size
end
end
assert_match
(
/DEPRECATION WARNING: This rake task is deprecated and will be removed in Rails 6.1/
,
stderr
)
end
private
def
run_rake_notes
(
command
=
"bin/rails notes"
)
boot_rails
load_tasks
def
run_rake_notes
(
command
=
"bin/rake notes"
)
Dir
.
chdir
(
app_path
)
do
output
=
`
#{
command
}
`
lines
=
output
.
scan
(
/\[([0-9\s]+)\]\s/
).
flatten
lines
=
output
.
scan
(
/\[([0-9\s]+)\]\s/
).
flatten
yield
output
,
lines
end
end
def
load_tasks
require
"rake"
require
"rdoc/task"
require
"rake/testtask"
Rails
.
application
.
load_tasks
end
def
boot_rails
require
"
#{
app_path
}
/config/environment"
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录