gpt4 book ai didi

ruby-on-rails - 在 rspec 中运行测试组

转载 作者:太空宇宙 更新时间:2023-11-03 18:09:07 26 4
gpt4 key购买 nike

我的应用程序有一些功能正在使用 httparty 服务从另一个网站获取数据。所以在运行http功能的测试时会花费很多时间。

- spec
-- services
--- http_request
---- test_http_a_spec.rb
---- test_http_b_spec.rb
--- component
---- test_component_c_spec.rb
---- test_component_d_spec.rb
--- models
---- test_model_e_spec.rb

那么除了 http_request 文件夹中的测试之外,我如何为所有测试运行 rspec test 呢?谢谢

最佳答案

你可能想用 rspec filters 标记你的 http 测试和 rspec tags .

例如,在spec/services/http_request/test_http_a_spec.rb中:

describe WhatEver
describe 'Testing', http: true do
it 'should work' do
# ...
end
end
end

然后,使用 rspec --tag ~http 运行测试。带有标签 http: true 的测试将不会被执行。

另一方面,如果您的 http 测试执行时间很长,您可能需要阅读 this article .

关于ruby-on-rails - 在 rspec 中运行测试组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37772745/

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