Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 00772d4

Browse files
committed
Introduce :skip metadata as alias for :pending.
This allows the two concepts to be separated in the future.
1 parent ae3e041 commit 00772d4

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/rspec/core/example.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ def self.delegate_to_metadata(*keys)
4141
keys.each { |key| define_method(key) { @metadata[key] } }
4242
end
4343

44-
delegate_to_metadata :full_description, :execution_result, :file_path, :pending, :location
44+
delegate_to_metadata :full_description, :execution_result, :file_path, :location, :skip
45+
46+
def pending
47+
@metadata.fetch(:pending, skip)
48+
end
4549

4650
# Returns the string submitted to `example` or its aliases (e.g.
4751
# `specify`, `it`, etc). If no string is submitted (e.g. `it { is_expected.to
@@ -94,7 +98,11 @@ def example_group
9498
@example_group_class
9599
end
96100

97-
alias_method :pending?, :pending
101+
def skipped?
102+
pending || skip
103+
end
104+
105+
alias_method :pending?, :skipped?
98106

99107
# @api private
100108
# instance_evals the block passed to the constructor in the context of
@@ -107,7 +115,7 @@ def run(example_group_instance, reporter)
107115
start(reporter)
108116

109117
begin
110-
unless pending || RSpec.configuration.dry_run?
118+
unless skipped? || RSpec.configuration.dry_run?
111119
with_around_each_hooks do
112120
begin
113121
run_before_each
@@ -260,7 +268,7 @@ def finish(reporter)
260268
record_finished 'pending', :pending_message => @pending_declared_in_example
261269
reporter.example_pending self
262270
true
263-
elsif pending
271+
elsif skipped?
264272
record_finished 'pending', :pending_message => String === pending ? pending : Pending::NO_REASON_GIVEN
265273
reporter.example_pending self
266274
true

lib/rspec/core/example_group.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def self.define_example_method(name, extra_options={})
5959
define_method(name) do |*all_args, &block|
6060
desc, *args = *all_args
6161
options = Metadata.build_hash_from(args)
62-
options.update(:pending => RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block
62+
options.update(:skip => RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block
6363
options.update(extra_options)
6464
examples << RSpec::Core::Example.new(self, desc, options, block)
6565
examples.last
@@ -102,16 +102,16 @@ def self.define_example_method(name, extra_options={})
102102

103103
# Shortcut to define an example with :pending => true
104104
# @see example
105-
define_example_method :pending, :pending => true
105+
define_example_method :pending, :skip => true
106106
# Shortcut to define an example with :pending => 'Temporarily disabled with xexample'
107107
# @see example
108-
define_example_method :xexample, :pending => 'Temporarily disabled with xexample'
108+
define_example_method :xexample, :skip => 'Temporarily disabled with xexample'
109109
# Shortcut to define an example with :pending => 'Temporarily disabled with xit'
110110
# @see example
111-
define_example_method :xit, :pending => 'Temporarily disabled with xit'
111+
define_example_method :xit, :skip => 'Temporarily disabled with xit'
112112
# Shortcut to define an example with :pending => 'Temporarily disabled with xspecify'
113113
# @see example
114-
define_example_method :xspecify, :pending => 'Temporarily disabled with xspecify'
114+
define_example_method :xspecify, :skip => 'Temporarily disabled with xspecify'
115115

116116
# Works like `alias_method :name, :example` with the added benefit of
117117
# assigning default metadata to the generated example.

0 commit comments

Comments
 (0)