class Object

Public Instance Methods

after(type=nil, &block) click to toggle source
# File lib/maxitest/vendor/around.rb, line 82
def after(type=nil, &block)
  include(Module.new do
    define_method(:teardown) do
      begin
        instance_exec(&block)
      ensure
        super()
      end
    end
  end)
end
around(*args, &block) click to toggle source
  • resume to call first part

  • execute test

  • resume fiber to execute last part

# File lib/maxitest/vendor/around.rb, line 59
def around(*args, &block)
  fib = nil
  before do
    fib = Fiber.new do |context, resume|
      begin
        context.instance_exec(resume, &block)
      rescue Object
        fib = :failed
        raise
      end
    end
    fib.resume(self, lambda { Fiber.yield })
  end
  after  { fib.resume if fib && fib != :failed }
end
before(type=nil, &block) click to toggle source
# File lib/maxitest/vendor/around.rb, line 77
def before(type=nil, &block)
  include Module.new { define_method(:setup) { super(); instance_exec(&block) } }
end
capture_exceptions(&block) click to toggle source
# File lib/maxitest/trap.rb, line 3
def capture_exceptions(&block)
  capture_exceptions_without_stop(&block)
rescue Interrupt
  Maxitest.interrupted = true
  self.failures << Minitest::UnexpectedError.new($!)
end
filter(*) click to toggle source
Calls superclass method
# File lib/maxitest/shorted_backtrace.rb, line 2
def filter(*)
  backtrace = super
  pwd = "#{Dir.pwd}/"
  section = pwd.size..-1
  backtrace.map { |b| b.start_with?(pwd) ? b[section] : b }
end
infect_an_assertion(_, new_name, *) click to toggle source
Calls superclass method
# File lib/maxitest/global_must.rb, line 5
  def infect_an_assertion(_, new_name, *)
    super # define with deprecation

    # remove old to avoid warnings from re-defining
    remove_method new_name

    # re-define without deprecation
    class_eval <<-EOM, __FILE__, __LINE__ + 1
      def #{new_name} *args
        Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
      end
    EOM
  end
let!(name, &block) click to toggle source
# File lib/maxitest/let_bang.rb, line 2
def let!(name, &block)
  let(name, &block)
  before { send(name) }
end
let_all(name, &block) click to toggle source
# File lib/maxitest/let_all.rb, line 2
def let_all(name, &block)
  cache = []
  define_method(name) do
    if cache.empty?
      cache[0] = instance_eval(&block)
    else
      cache[0]
    end
  end
end
run() click to toggle source
# File lib/maxitest/trap.rb, line 11
def run
  if Maxitest.interrupted
    # only things with class `Minitest::Skip` get counted as skips
    # we need to raise and capture to get a skip with a backtrace
    skip = begin
      raise Minitest::Skip, "Maxitest::Interrupted"
    rescue Minitest::Skip
      $!
    end
    self.failures = [skip]
    defined?(Minitest::Result) ? Minitest::Result.from(self) : self
  else
    run_without_stop
  end
end
setup() click to toggle source
# File lib/maxitest/xit.rb, line 4
def setup; end
teardown() click to toggle source
# File lib/maxitest/xit.rb, line 5
def teardown; end
xit(*args, &block) click to toggle source
# File lib/maxitest/xit.rb, line 2
def xit(*args, &block)
  describe "skip" do
    def setup; end
    def teardown; end
    it(*args)
  end
end