Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7896f35b
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,发现更多精彩内容 >>
提交
7896f35b
编写于
6月 19, 2012
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use system tmpdir rather than our own
上级
a6fd462a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
13 deletion
+26
-13
railties/lib/rails/generators/test_case.rb
railties/lib/rails/generators/test_case.rb
+10
-2
railties/test/isolation/abstract_unit.rb
railties/test/isolation/abstract_unit.rb
+11
-8
railties/test/railties/generators_test.rb
railties/test/railties/generators_test.rb
+5
-3
未找到文件。
railties/lib/rails/generators/test_case.rb
浏览文件 @
7896f35b
...
...
@@ -37,8 +37,16 @@ class TestCase < ActiveSupport::TestCase
self
.
current_path
=
File
.
expand_path
(
Dir
.
pwd
)
self
.
default_arguments
=
[]
setup
:destination_root_is_set?
,
:ensure_current_path
teardown
:ensure_current_path
def
setup
destination_root_is_set?
ensure_current_path
super
end
def
teardown
ensure_current_path
super
end
# Sets which generator should be tested:
#
...
...
railties/test/isolation/abstract_unit.rb
浏览文件 @
7896f35b
...
...
@@ -19,15 +19,18 @@
# to run the tests
require
"active_support/testing/isolation"
require
"active_support/core_ext/kernel/reporting"
require
'tmpdir'
module
TestHelpers
module
Paths
module_function
TMP_PATH
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
*
%w[.. .. tmp]
))
def
app_template_path
File
.
join
Dir
.
tmpdir
,
'app_template'
end
def
tmp_path
(
*
args
)
File
.
join
(
TMP_PATH
,
*
args
)
@tmp_path
||=
Dir
.
mktmpdir
end
def
app_path
(
*
args
)
...
...
@@ -95,7 +98,7 @@ def build_app(options = {})
ENV
[
'RAILS_ENV'
]
=
'development'
FileUtils
.
rm_rf
(
app_path
)
FileUtils
.
cp_r
(
tmp_path
(
'app_template'
)
,
app_path
)
FileUtils
.
cp_r
(
app_template_path
,
app_path
)
# Delete the initializers unless requested
unless
options
[
:initializers
]
...
...
@@ -272,18 +275,18 @@ class ActiveSupport::TestCase
Module
.
new
do
extend
TestHelpers
::
Paths
# Build a rails app
if
File
.
exist?
(
tmp
_path
)
FileUtils
.
rm_rf
(
tmp
_path
)
if
File
.
exist?
(
app_template
_path
)
FileUtils
.
rm_rf
(
app_template
_path
)
end
FileUtils
.
mkdir
(
tmp
_path
)
FileUtils
.
mkdir
(
app_template
_path
)
environment
=
File
.
expand_path
(
'../../../../load_paths'
,
__FILE__
)
if
File
.
exist?
(
"
#{
environment
}
.rb"
)
require_environment
=
"-r
#{
environment
}
"
end
`
#{
Gem
.
ruby
}
#{
require_environment
}
#{
RAILS_FRAMEWORK_ROOT
}
/railties/bin/rails new
#{
tmp_path
(
'app_template'
)
}
`
File
.
open
(
"
#{
tmp_path
}
/app_template
/config/boot.rb"
,
'w'
)
do
|
f
|
`
#{
Gem
.
ruby
}
#{
require_environment
}
#{
RAILS_FRAMEWORK_ROOT
}
/railties/bin/rails new
#{
app_template_path
}
`
File
.
open
(
"
#{
app_template_path
}
/config/boot.rb"
,
'w'
)
do
|
f
|
if
require_environment
f
.
puts
"Dir.chdir('
#{
File
.
dirname
(
environment
)
}
') do"
f
.
puts
" require '
#{
environment
}
'"
...
...
railties/test/railties/generators_test.rb
浏览文件 @
7896f35b
...
...
@@ -8,11 +8,13 @@ module RailtiesTests
class
GeneratorTest
<
Rails
::
Generators
::
TestCase
include
ActiveSupport
::
Testing
::
Isolation
TMP_PATH
=
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
*
%w[.. .. tmp]
))
self
.
destination_root
=
File
.
join
(
TMP_PATH
,
"foo_bar"
)
def
destination_root
tmp_path
'foo_bar'
end
def
tmp_path
(
*
args
)
File
.
join
(
TMP_PATH
,
*
args
)
@tmp_path
||=
Dir
.
mktmpdir
File
.
join
(
@tmp_path
,
*
args
)
end
def
engine_path
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录