Module: RSpec::Core::Pending
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | rspec-core/lib/rspec/core/pending.rb |
Overview
Provides methods to mark examples as pending. These methods are available to be called from within any example or hook.
Constant Summary
-
NOT_YET_IMPLEMENTED =
Internal use only
# File 'rspec-core/lib/rspec/core/pending.rb', line 29'Not yet implemented'
-
NO_REASON_GIVEN =
Internal use only
# File 'rspec-core/lib/rspec/core/pending.rb', line 26'No reason given'
Class Method Summary
-
.mark_fixed!(example)
Internal use only
Internal use only
Mark example as fixed.
-
.mark_pending!(example, message_or_bool)
Internal use only
Internal use only
Mark example as pending.
-
.mark_skipped!(example, message_or_bool)
Internal use only
Internal use only
Mark example as skipped.
Instance Method Summary
Class Method Details
.mark_fixed!(example)
Mark example as fixed.
# File 'rspec-core/lib/rspec/core/pending.rb', line 152
def self.mark_fixed!(example) example.execution_result.pending_fixed = true end
.mark_pending!(example, message_or_bool)
Mark example as pending.
# File 'rspec-core/lib/rspec/core/pending.rb', line 135
def self.mark_pending!(example, ) = if ! || !(String === ) NO_REASON_GIVEN else end example. [:pending] = true example.execution_result. = example.execution_result.pending_fixed = false end
.mark_skipped!(example, message_or_bool)
Mark example as skipped.
# File 'rspec-core/lib/rspec/core/pending.rb', line 124
def self.mark_skipped!(example, ) Pending.mark_pending! example, example. [:skip] = true end
Instance Method Details
#pending
#pending(message)
When using pending
inside an example body using this method hooks, such as ‘before(:example)`, have already be run. This means that a failure from the code in the before
hook will prevent the example from being considered pending, as the example body would not be executed. If you need to consider hooks as pending as well you can use the pending metadata as an alternative, e.g. `it “does something”, pending: “message”`.
Marks an example as pending. The rest of the example will still be executed, and if it passes the example will fail to indicate that the pending can be removed.
# File 'rspec-core/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
#skip(message)
Marks an example as pending and skips execution.
# File 'rspec-core/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