Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
655b8be8
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,发现更多精彩内容 >>
提交
655b8be8
编写于
5月 29, 2015
作者:
R
Ronak Jangir
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed use of mocha from railties actions_test
上级
c4cb751d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
27 deletion
+52
-27
railties/test/generators/actions_test.rb
railties/test/generators/actions_test.rb
+52
-27
未找到文件。
railties/test/generators/actions_test.rb
浏览文件 @
655b8be8
require
'generators/generators_test_helper'
require
'rails/generators/rails/app/app_generator'
require
'env_helpers'
require
'm
ocha/setup'
# FIXME: stop using mocha
require
'm
initest/mock'
class
ActionsTest
<
Rails
::
Generators
::
TestCase
include
GeneratorsTestHelper
...
...
@@ -12,11 +12,13 @@ class ActionsTest < Rails::Generators::TestCase
def
setup
Rails
.
application
=
TestApp
::
Application
@mock_generator
=
Minitest
::
Mock
.
new
super
end
def
teardown
Rails
.
application
=
TestApp
::
Application
.
instance
@mock_generator
.
verify
end
def
test_invoke_other_generator_with_shortcut
...
...
@@ -140,13 +142,18 @@ def test_environment_with_block_should_include_block_contents_in_environment_ini
end
def
test_git_with_symbol_should_run_command_using_git_scm
generator
.
expects
(
:run
).
once
.
with
(
'git init'
)
action
:git
,
:init
@mock_generator
.
expect
(
:call
,
nil
,
[
'git init'
])
generator
.
stub
(
:run
,
@mock_generator
)
do
action
:git
,
:init
end
end
def
test_git_with_hash_should_run_each_command_using_git_scm
generator
.
expects
(
:run
).
times
(
2
)
action
:git
,
rm:
'README'
,
add:
'.'
@mock_generator
.
expect
(
:call
,
nil
,
[
"git rm README"
])
@mock_generator
.
expect
(
:call
,
nil
,
[
"git add ."
])
generator
.
stub
(
:run
,
@mock_generator
)
do
action
:git
,
rm:
'README'
,
add:
'.'
end
end
def
test_vendor_should_write_data_to_file_in_vendor
...
...
@@ -170,46 +177,60 @@ def test_initializer_should_write_date_to_file_in_config_initializers
end
def
test_generate_should_run_script_generate_with_argument_and_options
generator
.
expects
(
:run_ruby_script
).
once
.
with
(
'bin/rails generate model MyModel'
,
verbose:
false
)
action
:generate
,
'model'
,
'MyModel'
@mock_generator
.
expect
(
:call
,
nil
,
[
'bin/rails generate model MyModel'
,
verbose:
false
])
generator
.
stub
(
:run_ruby_script
,
@mock_generator
)
do
action
:generate
,
'model'
,
'MyModel'
end
end
def
test_rake_should_run_rake_command_with_default_env
generator
.
expects
(
:run
).
once
.
with
(
"rake log:clear RAILS_ENV=development"
,
verbose:
false
)
with_rails_env
nil
do
action
:rake
,
'log:clear'
@mock_generator
.
expect
(
:call
,
nil
,
[
"rake log:clear RAILS_ENV=development"
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
with_rails_env
nil
do
action
:rake
,
'log:clear'
end
end
end
def
test_rake_with_env_option_should_run_rake_command_in_env
generator
.
expects
(
:run
).
once
.
with
(
'rake log:clear RAILS_ENV=production'
,
verbose:
false
)
action
:rake
,
'log:clear'
,
env:
'production'
@mock_generator
.
expect
(
:call
,
nil
,
[
'rake log:clear RAILS_ENV=production'
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
action
:rake
,
'log:clear'
,
env:
'production'
end
end
def
test_rake_with_rails_env_variable_should_run_rake_command_in_env
generator
.
expects
(
:run
).
once
.
with
(
'rake log:clear RAILS_ENV=production'
,
verbose:
false
)
with_rails_env
"production"
do
action
:rake
,
'log:clear'
@mock_generator
.
expect
(
:call
,
nil
,
[
'rake log:clear RAILS_ENV=production'
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
with_rails_env
"production"
do
action
:rake
,
'log:clear'
end
end
end
def
test_env_option_should_win_over_rails_env_variable_when_running_rake
generator
.
expects
(
:run
).
once
.
with
(
'rake log:clear RAILS_ENV=production'
,
verbose:
false
)
with_rails_env
"staging"
do
action
:rake
,
'log:clear'
,
env:
'production'
@mock_generator
.
expect
(
:call
,
nil
,
[
'rake log:clear RAILS_ENV=production'
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
with_rails_env
"staging"
do
action
:rake
,
'log:clear'
,
env:
'production'
end
end
end
def
test_rake_with_sudo_option_should_run_rake_command_with_sudo
generator
.
expects
(
:run
).
once
.
with
(
"sudo rake log:clear RAILS_ENV=development"
,
verbose:
false
)
with_rails_env
nil
do
action
:rake
,
'log:clear'
,
sudo:
true
@mock_generator
.
expect
(
:call
,
nil
,
[
"sudo rake log:clear RAILS_ENV=development"
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
with_rails_env
nil
do
action
:rake
,
'log:clear'
,
sudo:
true
end
end
end
def
test_capify_should_run_the_capify_command
generator
.
expects
(
:run
).
once
.
with
(
'capify .'
,
verbose:
false
)
action
:capify!
@mock_generator
.
expect
(
:call
,
nil
,
[
'capify .'
,
verbose:
false
])
generator
.
stub
(
:run
,
@mock_generator
)
do
action
:capify!
end
end
def
test_route_should_add_data_to_the_routes_block_in_config_routes
...
...
@@ -245,15 +266,19 @@ def test_route_should_add_data_with_an_new_line
def
test_readme
run_generator
Rails
::
Generators
::
AppGenerator
.
expects
(
:source_root
).
times
(
2
).
returns
(
destination_root
)
assert_match
"application up and running"
,
action
(
:readme
,
"README.md"
)
2
.
times
{
@mock_generator
.
expect
(
:call
,
destination_root
,[])
}
Rails
::
Generators
::
AppGenerator
.
stub
(
:source_root
,
@mock_generator
)
do
assert_match
"application up and running"
,
action
(
:readme
,
"README.md"
)
end
end
def
test_readme_with_quiet
generator
(
default_arguments
,
quiet:
true
)
run_generator
Rails
::
Generators
::
AppGenerator
.
expects
(
:source_root
).
times
(
2
).
returns
(
destination_root
)
assert_no_match
"application up and running"
,
action
(
:readme
,
"README.md"
)
2
.
times
{
@mock_generator
.
expect
(
:call
,
destination_root
,[])
}
Rails
::
Generators
::
AppGenerator
.
stub
(
:source_root
,
@mock_generator
)
do
assert_no_match
"application up and running"
,
action
(
:readme
,
"README.md"
)
end
end
def
test_log
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录