Module: RSpec::Core::Pending

Included in:
ExampleGroup
Defined in:
lib/rspec/core/pending.rb

Defined Under Namespace

Classes: PendingDeclaredInExample

Constant Summary collapse

DEFAULT_MESSAGE =
'No reason given'

Instance Method Summary collapse

Instance Method Details

#pending(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rspec/core/pending.rb', line 8

def pending(*args)
  return self.class.before(:each) { pending(*args) } unless example

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

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

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