paw*_*318 2 rspec ruby-on-rails
失败/错误:无法从回溯中找到匹配的行rspec-rails 3将不再自动从文件位置推断示例组的规范类型.您可以使用以下代码段明确选择加入此功能:
Run Code Online (Sandbox Code Playgroud)RSpec.configure do |config| config.infer_spec_type_from_file_location! end如果您希望通过元数据手动标记规范类型,您可以安全地忽略此警告并继续升级到RSpec 3而不解决它.
因为我不喜欢这个configure解决方案而不是如何通过元数据手动标记规范类型?
你可以通过散列值来设置实例或组任意元数据describe,it等
例如:
describe SomeController, :type => :controller do
...
end
Run Code Online (Sandbox Code Playgroud)
具有与依赖相同的效果infer_spec_type_from_file_location!(假设文件在spec/controllers中)
不同类型的规格是:
type: :modeltype: :controller type: :requesttype: :featuretype: :viewtype: :helpertype: :mailertype: :routing有关更多信息,请参阅Rspec的文档.
| 归档时间: |
|
| 查看次数: |
517 次 |
| 最近记录: |