Methods

Class Index [+]

Quicksearch

RSpec::Core::Pending

Constants

NO_REASON_GIVEN
NOT_YET_IMPLEMENTED

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
    # File lib/rspec/core/pending.rb, line 71
71:       def pending(*args)
72:         return self.class.before(:each) { pending(*args) } unless example
73: 
74:         options = args.last.is_a?(Hash) ? args.pop : {}
75:         message = args.first || NO_REASON_GIVEN
76: 
77:         if options[:unless] || (options.has_key?(:if) && !options[:if])
78:           return block_given? ? yield : nil
79:         end
80: 
81:         example.metadata[:pending] = true
82:         example.metadata[:execution_result][:pending_message] = message
83:         if block_given?
84:           begin
85:             result = begin
86:                        yield
87:                        example.example_group_instance.instance_eval { verify_mocks_for_rspec }
88:                      end
89:             example.metadata[:pending] = false
90:           rescue Exception => e
91:             example.execution_result[:exception] = e
92:           ensure
93:             teardown_mocks_for_rspec
94:           end
95:           raise PendingExampleFixedError.new if result
96:         end
97:         raise PendingDeclaredInExample.new(message)
98:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.