Rspec挂起导致测试失败


it 'should be an array and not be empty' do
  pending
  expect(a.class).to be(Array)
  expect(a.empty?).to be(false)
  expect(a.first.class).to be(ExampleClass)
end

运行rspec:

Failures:
  1) should be an array and not be empty FIXED
     Expected pending 'No reason given' to fail. No Error was raised.
     # ./spec/example_spec.rb:19

知道为什么这被列为失败吗?

从Rspec 3开始。x,挂起的规范实际上是运行的,如果它们通过了,它被认为是失败的(因为如果它通过了,那么Rspec认为它不应该挂起)。

你可以使用skip而不是pending来确保你的规范不会实际运行。

更多信息:https://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#changes-to-pending-semantics-and-introduction-of-skip

提示:

should be an array and not be empty FIXED

通过的内容将导致挂起测试失败。查看文档中的示例[1],[2]。

  1. RSpec 2
  2. RSpec 3

最新更新