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

发布于 2024-09-15 07:49:06 字数 335 浏览 3 评论 0原文

我在 Rails 3 RC 下安装了当前的 RSpec 2 Beta,如 GitHub 页面(和几个博客)中所述。一切正常,但我无法像某些博客上建议的那样关闭特定的生成器。

这是我在 ./config/application.rb 中所做的:

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

但是当执行“rails gscaffold Model name:string”时,这些视图规范仍然会生成。 我的设置有什么问题吗?

I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on the GitHub page (and several blogs). 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.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.
What's wrong with my setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明月夜 2024-09-22 07:49:06

您需要传递 :view_specs =>; false 选项也是如此。我不知道为什么控制器生成器(其中 :views => false 有效)和脚手架之间存在不同。我去问大卫。

You'll want to pass the :view_specs => false option too. I don't know why this is different between the controller generator (where :views => false has effect) and scaffold. I'll ask David.

ゝ杯具 2024-09-22 07:49:06

您无法停止模型规范的生成,这是必要的,如果您希望进入 rspec 生成器 model/model_generator.rb 的源代码,您会发现没有 class_option :model_spec ....

下面给出了允许的选项,除了 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 

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 ....

Options allowd are give below, except webrat that can also be added or

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 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文