配置待定失败输出

使用选项配置待定示例输出的格式(默认为:full

  RSpec.configure do |c|
    c.pending_failure_output = :no_backtrace
  end

允许的选项为:full:no_backtrace:skip

背景

给定一个名为“spec/example_spec.rb”的文件,其中包含

require "spec_helper"

RSpec.describe "something" do
  pending "will never happen again" do
    expect(Time.now.year).to eq(2021)
  end
end

默认情况下输出回溯和详细信息

给定一个名为“spec/spec_helper.rb”的文件,其中包含


我运行rspec spec

那么示例应该全部通过

并且输出应包含“待定:此处列出的失败是预期的,不会影响套件的状态”

并且输出应包含“1) something will never happen again”

并且输出应包含“expected: 2021”

并且输出应包含“./spec/example_spec.rb:5”。

pending_failure_output 设置为:no_backtrace 会隐藏回溯

给定一个名为“spec/spec_helper.rb”的文件,其中包含

RSpec.configure { |c| c.pending_failure_output = :no_backtrace }

我运行rspec spec

那么示例应该全部通过

并且输出应包含“待定:此处列出的失败是预期的,不会影响套件的状态”

并且输出应包含“1) something will never happen again”

并且输出应包含“expected: 2021”

并且输出不应包含“./spec/example_spec.rb:5”。

pending_failure_output 设置为:skip 会隐藏回溯

给定一个名为“spec/spec_helper.rb”的文件,其中包含

RSpec.configure { |c| c.pending_failure_output = :skip }

我运行rspec spec

那么示例应该全部通过

并且输出不应包含“待定:此处列出的失败是预期的,不会影响套件的状态”

并且输出不应包含“1) something will never happen again”

并且输出不应包含“expected: 2021”

并且输出不应包含“./spec/example_spec.rb:5”。