Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
3ffc77a9
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,发现更多精彩内容 >>
提交
3ffc77a9
编写于
8月 10, 2017
作者:
R
Rafael França
提交者:
GitHub
8月 10, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30164 from bogdanvlviv/improve-railties-generators-tests
Improve railties generators tests
上级
0e109b18
8cc5a6e1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
85 addition
and
45 deletion
+85
-45
railties/CHANGELOG.md
railties/CHANGELOG.md
+4
-0
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
...ies/lib/rails/generators/rails/plugin/plugin_generator.rb
+1
-1
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+30
-32
railties/test/generators/plugin_generator_test.rb
railties/test/generators/plugin_generator_test.rb
+50
-12
未找到文件。
railties/CHANGELOG.md
浏览文件 @
3ffc77a9
*
Add
`--skip-action-cable`
option to the plugin generator.
*bogdanvlviv*
*
Deprecate support of use
`Rails::Application`
subclass to start Rails server.
*Yuji Yaginuma*
...
...
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
浏览文件 @
3ffc77a9
...
...
@@ -86,7 +86,7 @@ def test
end
PASSTHROUGH_OPTIONS
=
[
:skip_active_record
,
:skip_action_mailer
,
:skip_javascript
,
:skip_sprockets
,
:database
,
:skip_active_record
,
:skip_action_mailer
,
:skip_javascript
,
:skip_
action_cable
,
:skip_
sprockets
,
:database
,
:javascript
,
:quiet
,
:pretend
,
:force
,
:skip
]
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
3ffc77a9
...
...
@@ -394,6 +394,15 @@ def test_generator_without_skips
end
end
def
test_default_frameworks_are_required_when_others_are_removed
run_generator
[
destination_root
,
"--skip-active-record"
,
"--skip-action-mailer"
,
"--skip-action-cable"
,
"--skip-sprockets"
]
assert_file
"config/application.rb"
,
/require\s+["']rails["']/
assert_file
"config/application.rb"
,
/require\s+["']active_model\/railtie["']/
assert_file
"config/application.rb"
,
/require\s+["']active_job\/railtie["']/
assert_file
"config/application.rb"
,
/require\s+["']action_controller\/railtie["']/
assert_file
"config/application.rb"
,
/require\s+["']action_view\/railtie["']/
end
def
test_generator_defaults_to_puma_version
run_generator
[
destination_root
]
assert_gem
"puma"
,
"'~> 3.7'"
...
...
@@ -449,22 +458,26 @@ def test_generator_has_assets_gems
def
test_generator_if_skip_sprockets_is_given
run_generator
[
destination_root
,
"--skip-sprockets"
]
assert_no_file
"config/initializers/assets.rb"
assert_file
"config/application.rb"
do
|
content
|
assert_match
(
/#\s+require\s+["']sprockets\/railtie["']/
,
content
)
end
assert_file
"config/application.rb"
,
/#\s+require\s+["']sprockets\/railtie["']/
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/sass-rails/
,
content
)
assert_no_match
(
/uglifier/
,
content
)
assert_no_match
(
/coffee-rails/
,
content
)
end
assert_file
"config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.assets\.debug
= true
/
,
content
)
assert_no_match
(
/config\.assets\.debug/
,
content
)
end
assert_file
"config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.assets\.digest = true/
,
content
)
assert_no_match
(
/config\.assets\.js_compressor = :uglifier/
,
content
)
assert_no_match
(
/config\.assets\.css_compressor = :sass/
,
content
)
assert_no_match
(
/config\.assets\.digest/
,
content
)
assert_no_match
(
/config\.assets\.js_compressor/
,
content
)
assert_no_match
(
/config\.assets\.css_compressor/
,
content
)
assert_no_match
(
/config\.assets\.compile/
,
content
)
end
end
...
...
@@ -473,7 +486,7 @@ def test_generator_if_skip_action_cable_is_given
assert_file
"config/application.rb"
,
/#\s+require\s+["']action_cable\/engine["']/
assert_no_file
"config/cable.yml"
assert_no_file
"app/assets/javascripts/cable.js"
assert_no_
file
"app/channels"
assert_no_
directory
"app/channels"
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/redis/
,
content
)
end
...
...
@@ -486,10 +499,15 @@ def test_action_cable_redis_gems
def
test_generator_if_skip_test_is_given
run_generator
[
destination_root
,
"--skip-test"
]
assert_file
"config/application.rb"
,
/#\s+require\s+["']rails\/test_unit\/railtie["']/
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/capybara/
,
content
)
assert_no_match
(
/selenium-webdriver/
,
content
)
end
assert_no_directory
(
"test"
)
end
def
test_generator_if_skip_system_test_is_given
...
...
@@ -498,6 +516,10 @@ def test_generator_if_skip_system_test_is_given
assert_no_match
(
/capybara/
,
content
)
assert_no_match
(
/selenium-webdriver/
,
content
)
end
assert_directory
(
"test"
)
assert_no_directory
(
"test/system"
)
end
def
test_does_not_generate_system_test_files_if_skip_system_test_is_given
...
...
@@ -654,18 +676,6 @@ def test_file_is_added_for_backwards_compatibility
assert_file
"lib/test_file.rb"
,
"heres test data"
end
def
test_tests_are_removed_from_frameworks_if_skip_test_is_given
run_generator
[
destination_root
,
"--skip-test"
]
assert_file
"config/application.rb"
,
/#\s+require\s+["']rails\/test_unit\/railtie["']/
end
def
test_no_active_record_or_tests_if_skips_given
run_generator
[
destination_root
,
"--skip-test"
,
"--skip-active-record"
]
assert_file
"config/application.rb"
,
/#\s+require\s+["']rails\/test_unit\/railtie["']/
assert_file
"config/application.rb"
,
/#\s+require\s+["']active_record\/railtie["']/
assert_file
"config/application.rb"
,
/\s+require\s+["']active_job\/railtie["']/
end
def
test_pretend_option
output
=
run_generator
[
File
.
join
(
destination_root
,
"myapp"
),
"--pretend"
]
assert_no_match
(
/run bundle install/
,
output
)
...
...
@@ -896,18 +906,6 @@ def test_system_tests_directory_generated
assert_directory
(
"test/system"
)
end
def
test_system_tests_are_not_generated_on_system_test_skip
run_generator
[
destination_root
,
"--skip-system-test"
]
assert_no_directory
(
"test/system"
)
end
def
test_system_tests_are_not_generated_on_test_skip
run_generator
[
destination_root
,
"--skip-test"
]
assert_no_directory
(
"test/system"
)
end
private
def
stub_rails_application
(
root
)
Rails
.
application
.
config
.
root
=
root
...
...
railties/test/generators/plugin_generator_test.rb
浏览文件 @
3ffc77a9
...
...
@@ -97,7 +97,7 @@ def test_generating_test_files_in_full_mode_without_unit_test_files
run_generator
[
destination_root
,
"-T"
,
"--full"
]
assert_no_directory
"test/integration/"
assert_no_
file
"test"
assert_no_
directory
"test"
assert_file
"Rakefile"
do
|
contents
|
assert_no_match
(
/APP_RAKEFILE/
,
contents
)
end
...
...
@@ -106,11 +106,28 @@ def test_generating_test_files_in_full_mode_without_unit_test_files
end
end
def
test_generating_adds_dummy_app_
in_full_mode_
without_sprockets
run_generator
[
destination_root
,
"-
S"
,
"--full
"
]
def
test_generating_adds_dummy_app_without_sprockets
run_generator
[
destination_root
,
"-
-skip-sprockets
"
]
assert_file
"test/dummy/config/environments/production.rb"
do
|
contents
|
assert_no_match
(
/config\.assets/
,
contents
)
assert_no_file
"test/dummy/config/initializers/assets.rb"
assert_file
"test/dummy/config/application.rb"
,
/#\s+require\s+["']sprockets\/railtie["']/
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/sass-rails/
,
content
)
assert_no_match
(
/uglifier/
,
content
)
assert_no_match
(
/coffee-rails/
,
content
)
end
assert_file
"test/dummy/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.assets\.debug/
,
content
)
end
assert_file
"test/dummy/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.assets\.digest/
,
content
)
assert_no_match
(
/config\.assets\.js_compressor/
,
content
)
assert_no_match
(
/config\.assets\.css_compressor/
,
content
)
assert_no_match
(
/config\.assets\.compile/
,
content
)
end
end
...
...
@@ -138,8 +155,8 @@ def test_ensure_that_plugin_options_are_not_passed_to_app_generator
def
test_ensure_that_test_dummy_can_be_generated_from_a_template
FileUtils
.
cd
(
Rails
.
root
)
run_generator
([
destination_root
,
"-m"
,
"lib/create_test_dummy_template.rb"
,
"--skip-test"
])
assert_
file
"spec/dummy"
assert_no_
file
"test"
assert_
directory
"spec/dummy"
assert_no_
directory
"test"
end
def
test_database_entry_is_generated_for_sqlite3_by_default_in_full_mode
...
...
@@ -173,9 +190,19 @@ def test_app_generator_without_skips
end
assert_file
"test/dummy/config/environments/production.rb"
do
|
content
|
assert_match
(
/# config\.action_mailer\.raise_delivery_errors = false/
,
content
)
assert_match
(
/^ config\.read_encrypted_secrets = true/
,
content
)
end
end
def
test_default_frameworks_are_required_when_others_are_removed
run_generator
[
destination_root
,
"--skip-active-record"
,
"--skip-action-mailer"
,
"--skip-action-cable"
,
"--skip-sprockets"
]
assert_file
"test/dummy/config/application.rb"
,
/require\s+["']rails["']/
assert_file
"test/dummy/config/application.rb"
,
/require\s+["']active_model\/railtie["']/
assert_file
"test/dummy/config/application.rb"
,
/require\s+["']active_job\/railtie["']/
assert_file
"test/dummy/config/application.rb"
,
/require\s+["']action_controller\/railtie["']/
assert_file
"test/dummy/config/application.rb"
,
/require\s+["']action_view\/railtie["']/
end
def
test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given
run_generator
[
destination_root
,
"--skip-active-record"
]
assert_file
"test/dummy/config/application.rb"
,
/#\s+require\s+["']active_record\/railtie["']/
...
...
@@ -201,6 +228,18 @@ def test_action_mailer_is_removed_from_frameworks_if_skip_action_mailer_is_given
assert_file
"test/dummy/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
assert_no_directory
"test/dummy/app/mailers"
end
def
test_action_cable_is_removed_from_frameworks_if_skip_action_cable_is_given
run_generator
[
destination_root
,
"--skip-action-cable"
]
assert_file
"test/dummy/config/application.rb"
,
/#\s+require\s+["']action_cable\/engine["']/
assert_no_file
"test/dummy/config/cable.yml"
assert_no_file
"test/dummy/app/assets/javascripts/cable.js"
assert_no_directory
"test/dummy/app/channels"
assert_file
"Gemfile"
do
|
content
|
assert_no_match
(
/redis/
,
content
)
end
end
def
test_ensure_that_database_option_is_passed_to_app_generator
...
...
@@ -463,10 +502,9 @@ def test_creating_dummy_application_with_different_name
def
test_creating_dummy_without_tests_but_with_dummy_path
run_generator
[
destination_root
,
"--dummy_path"
,
"spec/dummy"
,
"--skip-test"
]
assert_file
"spec/dummy"
assert_file
"spec/dummy/config/application.rb"
assert_no_file
"test"
assert_no_file
"test/test_helper.rb"
assert_directory
"spec/dummy"
assert_file
"spec/dummy/config/application.rb"
,
/#\s+require\s+["']rails\/test_unit\/railtie["']/
assert_no_directory
"test"
assert_file
".gitignore"
do
|
contents
|
assert_match
(
/spec\/dummy/
,
contents
)
end
...
...
@@ -503,7 +541,7 @@ def test_unnecessary_files_are_not_generated_in_dummy_application
def
test_skipping_test_files
run_generator
[
destination_root
,
"--skip-test"
]
assert_no_
file
"test"
assert_no_
directory
"test"
assert_file
".gitignore"
do
|
contents
|
assert_no_match
(
/test\/dummy/
,
contents
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录