【问题标题】:RSpec Retry Gem - Unable to implement retry attemptsRSpec Retry Gem - 无法实现重试尝试
【发布时间】:2018-02-22 03:47:56
【问题描述】:

我正在将 Rspec Retry gem 应用到我的项目中。我已将重试代码添加到 spec_helper.rb 中,并且正在使用此方法对其进行测试:

  it 'should randomly succeed', :retry => 3 do
    expect(rand(23)).to eq(1)
  end

但是,我无法让重试真正重新运行该方法。我正在努力弄清楚为什么它不会重试。这是控制台输出。

My console outputs the following:
C:\RSpecRetry>rspec spec/support/raise_error.rb
C:/RSpecRetry/spec/spec_helper.rb:100: warning: already initialized constant CONTINUE_SPEC
C:/RSpecRetry/spec/spec_helper.rb:95: warning: previous definition of CONTINUE_SPEC was here

1st Try error in ./spec/support/raise_error.rb:8:

expected: 1
     got: 17

(compared using ==)


RSpec::Retry: 2nd try ./spec/support/raise_error.rb:8
.

Finished in 1.07 seconds (files took 1.89 seconds to load)
1 example, 0 failures

【问题讨论】:

    标签: rspec


    【解决方案1】:

    据我所知,您的规范实际上已重试:

    • 第一次尝试得到 17 而不是 1 1st Try error in ./spec/support/raise_error.rb:8
    • 第二次尝试(幸运!)你得到了RSpec::Retry: 2nd try ./spec/support/raise_error.rb:8 .

    总结证实了这一点:

    1 example, 0 failures

    如果您不想看到失败的尝试,请使用 config(尤其是前两个)

    【讨论】:

      猜你喜欢
      • 2021-02-07
      • 2019-08-12
      • 1970-01-01
      • 2011-01-14
      • 1970-01-01
      • 1970-01-01
      • 2022-06-24
      • 1970-01-01
      • 2019-03-27
      相关资源
      最近更新 更多