简体   繁体   English

如何在Rails 3中关闭RSpec 2的生成器?

[英]How to turn off generators for RSpec 2 in Rails 3?

I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on the GitHub page (and several blogs). 我在GitHub页面(以及几个博客)中提到的Rails 3 RC下安装了当前的RSpec 2 Beta。 Everything works fine, but I am not able to turn off specific generators like advised on some blogs. 一切正常,但我无法关闭某些博客上建议的特定生成器。

Here is what I do in ./config/application.rb: 这是我在./config/application.rb中所做的事情:

config.generators do |g|
  g.test_framework :rspec, :fixtures => false, :views => false
end

But when doing a "rails g scaffold Model name:string" those view specs are still generated. 但是当做“rails g scaffold Model name:string”时,仍会生成那些视图规格。 What's wrong with my setup? 我的设置有什么问题?

You'll want to pass the :view_specs => false option too. 您还需要传递:view_specs => false选项。 I don't know why this is different between the controller generator (where :views => false has effect) and scaffold. 我不知道为什么控制器生成器(其中:views => false有效)和脚手架之间存在差异。 I'll ask David. 我会问大卫。

You can not stop generation of model spec, that is necessary and if you hope into the source code for rspec generator model/model_generator.rb you'll find there is no class_option :model_spec .... 你不能停止生成模型规范,这是必要的,如果你希望进入rspec生成器模型/ model_generator.rb的源代码,你会发现没有class_option:model_spec ....

Options allowd are give below, except webrat that can also be added or 允许的选项在下面给出,除了也可以添加的webrat或

config.generators do |g| 
  g.test_framework :rspec, :view_specs => false, :controller_specs => false, 
    :helper_specs => false, :routing_specs => false, :fixture => true,
    :fixture_replacement => "factory_girl"
end 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM