gpt4 book ai didi

ruby-on-rails - 通过元数据手动标记规范类型

转载 作者:行者123 更新时间:2023-12-04 03:33:30 25 4
gpt4 key购买 nike

Failure/Error: Unable to find matching line from backtrace rspec-rails 3 will no longer automatically infer an example group's spec type from the file location. You can explicitly opt-in to this feature using this snippet:

   RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end

If you wish to manually label spec types via metadata you can safely ignore this warning and continue upgrading to RSpec 3 without addressing it.

因为我不喜欢 configure 解决方案,所以我如何才能真正通过元数据手动标记规范类型

最佳答案

您可以通过将哈希传递给describeit等来设置示例或组的任意元数据

例如:

describe SomeController, :type => :controller do
...
end

与依赖infer_spec_type_from_file_location!具有相同的效果(假设文件位于spec/controllers中)

不同类型的规范是:

  • 型号规范:类型::model
  • Controller 规范:类型::controller
  • 请求规范:类型::request
  • 功能规范:类型::feature
  • 查看规范:类型::view
  • 帮助程序规范:类型::helper
  • 邮件程序规范:类型::mailer
  • 路由规范:类型::routing

有关详细信息,请参阅Rspec's documentation .

关于ruby-on-rails - 通过元数据手动标记规范类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25144919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com