Skip to content

Commit

Permalink
Introduce :skip metadata as alias for :pending.
Browse files Browse the repository at this point in the history
This allows the two concepts to be separated in the future.
  • Loading branch information
xaviershay committed Jan 25, 2014
1 parent ae3e041 commit 00772d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 12 additions & 4 deletions lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def self.delegate_to_metadata(*keys)
keys.each { |key| define_method(key) { @metadata[key] } }
end

delegate_to_metadata :full_description, :execution_result, :file_path, :pending, :location
delegate_to_metadata :full_description, :execution_result, :file_path, :location, :skip

def pending
@metadata.fetch(:pending, skip)
end

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

alias_method :pending?, :pending
def skipped?
pending || skip
end

alias_method :pending?, :skipped?

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

begin
unless pending || RSpec.configuration.dry_run?
unless skipped? || RSpec.configuration.dry_run?
with_around_each_hooks do
begin
run_before_each
Expand Down Expand Up @@ -260,7 +268,7 @@ def finish(reporter)
record_finished 'pending', :pending_message => @pending_declared_in_example
reporter.example_pending self
true
elsif pending
elsif skipped?
record_finished 'pending', :pending_message => String === pending ? pending : Pending::NO_REASON_GIVEN
reporter.example_pending self
true
Expand Down
10 changes: 5 additions & 5 deletions lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def self.define_example_method(name, extra_options={})
define_method(name) do |*all_args, &block|
desc, *args = *all_args
options = Metadata.build_hash_from(args)
options.update(:pending => RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block
options.update(:skip => RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block
options.update(extra_options)
examples << RSpec::Core::Example.new(self, desc, options, block)
examples.last
Expand Down Expand Up @@ -102,16 +102,16 @@ def self.define_example_method(name, extra_options={})

# Shortcut to define an example with :pending => true
# @see example
define_example_method :pending, :pending => true
define_example_method :pending, :skip => true
# Shortcut to define an example with :pending => 'Temporarily disabled with xexample'
# @see example
define_example_method :xexample, :pending => 'Temporarily disabled with xexample'
define_example_method :xexample, :skip => 'Temporarily disabled with xexample'
# Shortcut to define an example with :pending => 'Temporarily disabled with xit'
# @see example
define_example_method :xit, :pending => 'Temporarily disabled with xit'
define_example_method :xit, :skip => 'Temporarily disabled with xit'
# Shortcut to define an example with :pending => 'Temporarily disabled with xspecify'
# @see example
define_example_method :xspecify, :pending => 'Temporarily disabled with xspecify'
define_example_method :xspecify, :skip => 'Temporarily disabled with xspecify'

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

0 comments on commit 00772d4

Please sign in to comment.