File: pending.rb

package info (click to toggle)
ruby-maxitest 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 444 kB
  • sloc: ruby: 1,339; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
module Maxitest
  module Pending
    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]

      # allow user to for example mark test only pending on CI with `if: ENV["CI"]`
      return yield if kwargs.fetch(:if, true) == false

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

Minitest::Test.include Maxitest::Pending