gpt4 book ai didi

ruby - RSpec 在使用 -f 格式化程序时抛出参数错误

转载 作者:数据小太阳 更新时间:2023-10-29 07:59:01 25 4
gpt4 key购买 nike

我正在使用 ruby​​ 和 rspec 与 watir 一起编写自动化测试用例。

C:\Users\san\Dragon>gem list 'rspec'

*** LOCAL GEMS ***

rspec (3.4.0, 2.14.1)
rspec-core (3.4.3, 2.14.8)
rspec-expectations (3.4.0, 2.14.5)
rspec-mocks (3.4.1, 2.14.6)
rspec-support (3.4.1)

当我使用以下命令运行测试用例时。

C:\Users\san\Dragon>rspec -f spec\sampletest_spec.rb:65

我遇到了这个错误

C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/formatters.rb:173:in `find_formatter': Formatter 'spec\sampletest_spec.rb:65' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-.4.3/lib/rspec/core/formatters.rb:141:in `add'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:767:in `add_formatter'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `block in load_formatters_into'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `load_formatters_into'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:23:in `configure'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:105:in `setup'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:92:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:78:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:45:in `invoke'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/exe/rspec:4:in `<top (required)>'
from C:/Ruby193/bin/rspec:23:in `load'
from C:/Ruby193/bin/rspec:23:in `<main>'

同样的错误

rspec spec\sampletest_spec.rb --格式文档
rspec --format spec\sampletest_spec.rb

最佳答案

你把事情搞砸了。 --format/-f 参数期望将格式描述本身传递给它,同时传递测试文件的名称。

我不知道为什么有问题

rspec spec\sampletest_spec.rb --format documentation

这个必须工作。但无论如何,最简单的解决方案是在项目根目录中创建具有以下内容的 .rspec 文件:

--format documentation

是的,唯一的线路。创建此文件后,只需运行

rspec spec\sampletest_spec.rb

RSpec 将从该文件中读取配置并应用所需的格式。

关于ruby - RSpec 在使用 -f 格式化程序时抛出参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789266/

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