模块: RSpec::Core::Pending
- 包含于
- ExampleGroup
- 定义于
- lib/rspec/core/pending.rb
概述
提供标记示例为待处理的方法。这些方法可以在任何示例或钩子中调用。
定义在命名空间下
实例方法摘要 收起
-
#pending(message = nil, &_block) ⇒ void
将示例标记为待处理。
-
#skip(message = nil) ⇒ void
将示例标记为待处理并跳过执行。
实例方法详细信息
#pending ⇒ void #pending(message) ⇒ void
注意
当在示例主体中使用 pending
时,使用此方法的钩子(如 before(:example)
)已运行。这意味着 before
钩子中的代码失败将阻止示例被视为待处理,因为示例主体不会被执行。如果您需要将钩子也视为待处理,可以使用待处理元数据作为替代方法,例如 it "does something", pending: "message"
。
将示例标记为待处理。示例的其余部分将继续执行,如果它通过,则示例将失败,表明可以删除待处理项。
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/rspec/core/pending.rb', line 62 def pending(=nil, &_block) current_example = RSpec.current_example if block_given? raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '') |The semantics of `RSpec::Core::Pending#pending` have changed in |RSpec 3. In RSpec 2.x, it caused the example to be skipped. In |RSpec 3, the rest of the example is still run but is expected to |fail, and will be marked as a failure (rather than as pending) if |the example passes. | |Passing a block within an example is now deprecated. Marking the |example as pending provides the same behavior in RSpec 3 which was |provided only by the block in RSpec 2.x. | |Move the code in the block provided to `pending` into the rest of |the example body. | |Called from #{CallerFilter.first_non_rspec_line}. | EOS elsif current_example Pending.mark_pending! current_example, else raise "`pending` may not be used outside of examples, such as in " \ "before(:context). Maybe you want `skip`?" end end |
#skip ⇒ void #skip(message) ⇒ void
将示例标记为待处理并跳过执行。
110 111 112 113 114 115 116 |
# File 'lib/rspec/core/pending.rb', line 110 def skip(=nil) current_example = RSpec.current_example Pending.mark_skipped!(current_example, ) if current_example raise SkipDeclaredInExample.new() end |