失败测试中的 rspec 待定结果
-
21-12-2019 - |
题
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
以确保您的规范实际上并未运行。
不隶属于 StackOverflow