Module: RSpec::Core::Pending

### Home Classes Methods

### In Files

- lib/rspec/core/pending.rb

### Namespace

- CLASS RSpec::Core::Pending::PendingDeclaredInExample
- CLASS RSpec::Core::Pending::PendingExampleFixedError

### Methods

- #pending

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# RSpec::Core::Pending

### Constants

NOT_YET_IMPLEMENTED
NO_REASON_GIVEN

### Public Instance Methods

pending(*args) click to toggle source

@overload pending() @overload pending(message) @overload pending(message, &block)

Stops execution of an example, and reports it as pending. Takes an optional message and block.

@param [String] message optional message to add to the summary report. @param [Block] block optional block. If it fails, the example is

    reported as pending. If it executes cleanly the example fails.

@example

    describe "an example" do
      # reported as "Pending: no reason given"
      it "is pending with no message" do
        pending
        this_does_not_get_executed
      end

      # reported as "Pending: something else getting finished"
      it "is pending with a custom message" do
        pending("something else getting finished")
        this_does_not_get_executed
      end

      # reported as "Pending: something else getting finished"
      it "is pending with a failing block" do
        pending("something else getting finished") do
          raise "this is the failure"
        end
      end

      # reported as failure, saying we expected the block to fail but
      # it passed.
      it "is pending with a passing block" do
        pending("something else getting finished") do
          true.should be(true)
        end
      end
    end

@note `before(:each)` 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:

        it "does something", :pending => true do
          # ...
        end

    or pass `:pending => "something else getting finished"` to add a
    message to the summary report:

        it "does something", :pending => "something else getting finished" do
          # ...
        end

    # File lib/rspec/core/pending.rb, line 78
    def pending(*args)
      return self.class.before(:each) { pending(*args) } unless example

      options = args.last.is_a?(Hash) ? args.pop : {}
      message = args.first || NO_REASON_GIVEN

      if options[:unless] || (options.has_key?(:if) && !options[:if])
        return block_given? ? yield : nil
      end

      example.metadata[:pending] = true
      example.metadata[:execution_result][:pending_message] = message
      if block_given?
        begin
          result = begin
                     yield
                     example.example_group_instance.instance_eval { verify_mocks_for_rspec }
                     true
                   end
          example.metadata[:pending] = false
        rescue Exception => e
          example.execution_result[:exception] = e
        ensure
          teardown_mocks_for_rspec
        end
        raise PendingExampleFixedError.new if result
      end
      raise PendingDeclaredInExample.new(message)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.