Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify pending docs #2872

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions lib/rspec/core/pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PendingExampleFixedError < StandardError; end
# @param message [String] optional message to add to the summary report.
#
# @example
# describe "an example" do
# describe "some behaviour" do
# # reported as "Pending: no reason given"
# it "is pending with no message" do
# pending
Expand All @@ -52,21 +52,42 @@ class PendingExampleFixedError < StandardError; end
# end
# end
#
# @note `before(:example)` hooks are eval'd when you use the `pending`
# method within an example. If you want to declare an example `pending`
# and bypass the `before` hooks as well, you can pass `:pending => true`
# to the `it` method:
# @example Alternatively, you can use the `pending` example alias method:
#
# it "does something", :pending => true do
# describe "SomeClass" do
# pending "does not implement something yet" do
# # ...
# end
# end
#
# or pass `:pending => "something else getting finished"` to add a
# message to the summary report:
# or specify metadata on an example:
#
# it "does something", :pending => "something else getting finished" do
# # ...
# end
# it "does this", :pending => "is not yet implemented" do
# # ...
# end
#
# even without an explicit pending message:
#
# it "does something", :pending do
# # ...
# end
#
# @note There is a difference between using `pending` inside the example
# body and `pending` example group alias/`pending` metadata. In the case
# when the failure is caused by the code in the `before` hook, the example
# would not be considered pending, as the example body wouldn't be reached.
# If you intend the failure in the `before` hook to be considered a part
# of the example, use the latter.
#
# @example Failure in `before` hook causes the example to fail
# before { fail 'BOOM' }
# it 'fails' do
# pending 'this never gets executed'
# end
#
# pending 'is considered pending' do
# not_implemented
# end
def pending(message=nil)
current_example = RSpec.current_example

Expand Down