在rails 4.2.0 / rspec 3.2.2 / rspec-rails 3.2.1中。我正在尝试禁用生成新模型时生成的规范。我正在使用与rails约定不同的spec文件夹结构,并且不想为每个新模型删除/移动生成的spec文件。我尝试添加导轨指南和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
之前有人解决了这个问题吗?
答案 0 :(得分:7)
如果要禁用所有生成器,只需将test_framework
设置为falsey:
config.generators do |g|
g.test_framework nil
end
您遗憾地无法仅从发生器中禁用模型规格。 They're not optional