Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0ce117fa
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,发现更多精彩内容 >>
提交
0ce117fa
编写于
9月 23, 2016
作者:
A
Arthur Nogueira Neves
提交者:
GitHub
9月 23, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26515 from grosser/grosser/after_run
support minitest after_run
上级
549ee51b
3f2e861d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
4 deletion
+40
-4
railties/CHANGELOG.md
railties/CHANGELOG.md
+4
-0
railties/lib/rails/commands/test.rb
railties/lib/rails/commands/test.rb
+3
-3
railties/test/application/test_test.rb
railties/test/application/test_test.rb
+33
-1
未找到文件。
railties/CHANGELOG.md
浏览文件 @
0ce117fa
*
Run
`Minitest.after_run`
hooks when running
`rails test`
.
*Michael Grosser*
*
Run
`before_configuration`
callbacks as soon as application constant
inherits from
`Rails::Application`
.
...
...
railties/lib/rails/commands/test.rb
浏览文件 @
0ce117fa
require
"rails/test_unit/minitest_plugin"
if
defined?
(
ENGINE_ROOT
)
$
:
<<
File
.
expand_path
(
"test"
,
ENGINE_ROOT
)
$
LOAD_PATH
<<
File
.
expand_path
(
"test"
,
ENGINE_ROOT
)
else
$
:
<<
File
.
expand_path
(
"../../test"
,
APP_PATH
)
$
LOAD_PATH
<<
File
.
expand_path
(
"../../test"
,
APP_PATH
)
end
exit
Minitest
.
run
(
ARGV
)
require
"minitest/autorun"
railties/test/application/test_test.rb
浏览文件 @
0ce117fa
...
...
@@ -12,7 +12,7 @@ def teardown
teardown_app
end
test
"
truth
"
do
test
"
simple successful test
"
do
app_file
"test/unit/foo_test.rb"
,
<<-
RUBY
require 'test_helper'
...
...
@@ -26,6 +26,38 @@ def test_truth
assert_successful_test_run
"unit/foo_test.rb"
end
test
"after_run"
do
app_file
"test/unit/foo_test.rb"
,
<<-
RUBY
require 'test_helper'
Minitest.after_run { puts "WORLD" }
Minitest.after_run { puts "HELLO" }
class FooTest < ActiveSupport::TestCase
def test_truth
assert true
end
end
RUBY
result
=
assert_successful_test_run
"unit/foo_test.rb"
assert_equal
[
"HELLO"
,
"WORLD"
],
result
.
scan
(
/HELLO|WORLD/
)
# only once and in correct order
end
test
"simple failed test"
do
app_file
"test/unit/foo_test.rb"
,
<<-
RUBY
require 'test_helper'
class FooTest < ActiveSupport::TestCase
def test_truth
assert false
end
end
RUBY
assert_unsuccessful_run
"unit/foo_test.rb"
,
"Failed assertion"
end
test
"integration test"
do
controller
"posts"
,
<<-
RUBY
class PostsController < ActionController::Base
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录