似乎无法禁用 rails 生成器生成规范
Can't seem to disable rails generator generating specs
在rails4.2.0/rspec3.2.2/rspec-rails3.2.1。我试图禁用生成新模型时生成的规范。我正在使用不同于 rails 约定的规范文件夹结构,并且不希望 delete/move 为每个新模型生成规范文件。我尝试添加 rails 指南和 What is the syntax to skip creating tests, assets & helpers when running `rails generate controller`?
中提到的生成器配置
我的 config/application.rb 包含这个:
config.generators do |g|
g.test_framework :rspec
g.model_specs false
g.view_specs false
g.helper_specs false
g.controller_specs false
g.model_spec false
g.helper_specs false
g.request_specs false
g.feature_specs false
end
而且我还在:
$rails g model category
invoke active_record
create db/migrate/20150416174523_create_categories.rb
create app/models/category.rb
invoke rspec
create spec/models/category_spec.rb
invoke factory_girl
create spec/factories/categories.rb
即使我明确添加标签:
$rails g model category --no-model-specs
invoke active_record
create db/migrate/20150416174908_create_categories.rb
create app/models/category.rb
invoke rspec
create spec/models/category_spec.rb
invoke factory_girl
create spec/factories/categories.rb
有人解决过这个问题吗?
如果您想禁用所有生成器,只需将 test_framework
设置为假值即可:
config.generators do |g|
g.test_framework nil
end
遗憾的是,您无法单独禁用生成器的模型规格。 They're not optional.
在rails4.2.0/rspec3.2.2/rspec-rails3.2.1。我试图禁用生成新模型时生成的规范。我正在使用不同于 rails 约定的规范文件夹结构,并且不希望 delete/move 为每个新模型生成规范文件。我尝试添加 rails 指南和 What is the syntax to skip creating tests, assets & helpers when running `rails generate controller`?
中提到的生成器配置我的 config/application.rb 包含这个:
config.generators do |g|
g.test_framework :rspec
g.model_specs false
g.view_specs false
g.helper_specs false
g.controller_specs false
g.model_spec false
g.helper_specs false
g.request_specs false
g.feature_specs false
end
而且我还在:
$rails g model category
invoke active_record
create db/migrate/20150416174523_create_categories.rb
create app/models/category.rb
invoke rspec
create spec/models/category_spec.rb
invoke factory_girl
create spec/factories/categories.rb
即使我明确添加标签:
$rails g model category --no-model-specs
invoke active_record
create db/migrate/20150416174908_create_categories.rb
create app/models/category.rb
invoke rspec
create spec/models/category_spec.rb
invoke factory_girl
create spec/factories/categories.rb
有人解决过这个问题吗?
如果您想禁用所有生成器,只需将 test_framework
设置为假值即可:
config.generators do |g|
g.test_framework nil
end
遗憾的是,您无法单独禁用生成器的模型规格。 They're not optional.