Module: RSpec::Todo

Defined in:
lib/rspec/todo.rb

Instance Method Summary collapse

Instance Method Details

#not_todo(reason = nil, *errors_expected, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rspec/todo.rb', line 19

def not_todo(reason = nil, *errors_expected, &block)
  if block_given?
    begin
      yield
    rescue RSpec::Expectations::ExpectationNotMetError, *errors_expected => e
      # do nothing
    else
      if reason
        raise(reason)
      else
        raise "not todo but passed"
      end
    end
  else
    pending(reason)
  end
end

#todo(reason = nil, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rspec/todo.rb', line 3

def todo(reason = nil, &block)
  if block_given?
    begin
      yield
    rescue => e
      if reason
        pending(reason)
      else
        pending(e.inspect)
      end
    end
  else
    pending(reason)
  end
end