diff --git a/lib/rspec/core/example.rb b/lib/rspec/core/example.rb index fb010eb435..c3b0c3bbf4 100644 --- a/lib/rspec/core/example.rb +++ b/lib/rspec/core/example.rb @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/lib/rspec/core/example_group.rb b/lib/rspec/core/example_group.rb index bc9580b61e..8163d8e363 100644 --- a/lib/rspec/core/example_group.rb +++ b/lib/rspec/core/example_group.rb @@ -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 @@ -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.