Module: Minitest::Hooks

Included in:
HooksSpec
Defined in:
lib/minitest/hooks/test.rb

Overview

Add support for around and before_all/after_all/around_all hooks to minitest spec classes.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object

Add the class methods to the class. Also, include an additional module in the class that before(:all) and after(:all) methods work on a class that directly includes this module.



9
10
11
12
13
14
# File 'lib/minitest/hooks/test.rb', line 9

def self.included(mod)
  super
  mod.instance_exec do
    extend(Minitest::Hooks::ClassMethods)
  end
end

Instance Method Details

#after_allObject

Empty method, necessary so that super calls in spec subclasses work.



21
22
# File 'lib/minitest/hooks/test.rb', line 21

def after_all
end

#aroundObject

Method that just yields, so that super calls in spec subclasses work.



30
31
32
# File 'lib/minitest/hooks/test.rb', line 30

def around
  yield
end

#around_allObject

Method that just yields, so that super calls in spec subclasses work.



25
26
27
# File 'lib/minitest/hooks/test.rb', line 25

def around_all
  yield
end

#before_allObject

Empty method, necessary so that super calls in spec subclasses work.



17
18
# File 'lib/minitest/hooks/test.rb', line 17

def before_all
end

#time_itObject

Run around hook inside, since time_it is run around every spec.



35
36
37
38
39
40
41
# File 'lib/minitest/hooks/test.rb', line 35

def time_it
  super do
    around do
      yield
    end
  end
end