Module: Maxitest::Pending

Defined in:
lib/maxitest/pending.rb

Instance Method Summary collapse

Instance Method Details

#pending(reason = nil, **kwargs) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/maxitest/pending.rb', line 3

def pending(reason=nil, **kwargs)
  raise ArgumentError, "Need a block to execute" unless block_given?
  raise ArgumentError, "Only :if option is supported" if (kwargs.keys | [:if] != [:if])
  return yield if kwargs.fetch(:if, true) == false # allow user to for example mark test only pending on CI with `if: ENV["CI"]`

  begin
    yield # execute test
  rescue StandardError, Minitest::Assertion
    skip reason # test failed as expected
  else
    flunk "Test is fixed, remove `pending`"
  end
end