禁用请求和路由规范的生成? [RS规格]

发布于 2024-11-23 17:31:27 字数 517 浏览 2 评论 0原文

每当我生成脚手架时,Rspec 生成器总是创建如下所示的规范:

  invoke    rspec
  create      spec/controllers/stars_controller_spec.rb
  invoke      helper
  create      spec/routing/stars_routing_spec.rb
  invoke      rspec
  create        spec/requests/stars_spec.rb

如何确保这些规范永远不会生成?我尝试像这样设置配置设置,但没有帮助:

  config.generators do |g|
   g.test_framework :rspec, :fixture => true, :views => false
   g.view_specs false
   g.integration_specs false
   g.helper_specs false
  end

Whenever I generate a scaffold, Rspec generator always creates specs like the following:

  invoke    rspec
  create      spec/controllers/stars_controller_spec.rb
  invoke      helper
  create      spec/routing/stars_routing_spec.rb
  invoke      rspec
  create        spec/requests/stars_spec.rb

How can I make sure that these are never generated? I tried setting configuration settings like this, but it didn't help:

  config.generators do |g|
   g.test_framework :rspec, :fixture => true, :views => false
   g.view_specs false
   g.integration_specs false
   g.helper_specs false
  end

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

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

发布评论

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

评论(2

度的依靠╰つ 2024-11-30 17:31:28
config.generators do |g|
  g.test_framework :rspec,
    :view_specs    => false,
    :request_specs => false,
    :routing_specs => false
end

ps - 查看文档了解更多信息。

config.generators do |g|
  g.test_framework :rspec,
    :view_specs    => false,
    :request_specs => false,
    :routing_specs => false
end

ps - see the docs for more info.

甜尕妞 2024-11-30 17:31:28

如何找到这些选项?

文档可能已过时。但是,可以在 RSpec Rails 库中找到选项列表。

class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
class_option :request_specs,    type: :boolean, default: true,  desc: "Generate request specs"
class_option :view_specs,       type: :boolean, default: true,  desc: "Generate view specs"
class_option :helper_specs,     type: :boolean, default: true,  desc: "Generate helper specs"
class_option :routing_specs,    type: :boolean, default: true,  desc: "Generate routing specs"

How can you find these options?

Documentation can be out of date. However, the list of options can be found in RSpec Rails library.

class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
class_option :request_specs,    type: :boolean, default: true,  desc: "Generate request specs"
class_option :view_specs,       type: :boolean, default: true,  desc: "Generate view specs"
class_option :helper_specs,     type: :boolean, default: true,  desc: "Generate helper specs"
class_option :routing_specs,    type: :boolean, default: true,  desc: "Generate routing specs"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文