使用 `pending` 对示例进行操作
RSpec 提供了许多不同的方法来指示示例被禁用,正在等待某些操作。
以失败的示例 `pending` 任意原因
给定一个名为“pending_without_block_spec.rb”的文件,其中包含
RSpec.describe "an example" do
it "is implemented but waiting" do
pending("something else getting finished")
fail
end
end
当我运行 `rspec pending_without_block_spec.rb`
那么退出状态应该为 0
并且输出应该包含“1 个示例,0 个失败,1 个待处理”
并且输出应该包含
Pending: (Failures listed here are expected and do not affect your suite's status)
1) an example is implemented but waiting
# something else getting finished
以通过的示例 `pending` 任意原因
给定一个名为“pending_with_passing_example_spec.rb”的文件,其中包含
RSpec.describe "an example" do
it "is implemented but waiting" do
pending("something else getting finished")
expect(1).to be(1)
end
end
当我运行 `rspec pending_with_passing_example_spec.rb`
那么退出状态不应为 0
并且输出应该包含“1 个示例,1 个失败”
并且输出应该包含“已修复”
并且输出应该包含“预期待处理“其他事情完成”将失败。没有引发错误。”
并且输出应该包含“pending_with_passing_example_spec.rb:2”。
对当前通过的示例 `pending`
给定一个名为“pending_with_passing_block_spec.rb”的文件,其中包含
RSpec.describe "an example" do
pending("something else getting finished") do
expect(1).to eq(1)
end
end
当我运行 `rspec pending_with_passing_block_spec.rb`
那么退出状态不应为 0
并且输出应该包含“1 个示例,1 个失败”
并且输出应该包含“已修复”
并且输出应该包含“预期待处理“未给出原因”将失败。没有引发错误。”
并且输出应该包含“pending_with_passing_block_spec.rb:2”。
对当前通过的示例 `pending`,并给出原因
给定一个名为“pending_with_passing_block_spec.rb”的文件,其中包含
RSpec.describe "an example" do
example("something else getting finished", :pending => 'unimplemented') do
expect(1).to eq(1)
end
end
当我运行 `rspec pending_with_passing_block_spec.rb`
那么退出状态不应为 0
并且输出应该包含“1 个示例,1 个失败”
并且输出应该包含“已修复”
并且输出应该包含“预期待处理“未实现”将失败。没有引发错误。”
并且输出应该包含“pending_with_passing_block_spec.rb:2”。