Class: WithModel::MiniTestLifeCycle

Inherits:
Module
  • Object
show all
Defined in:
lib/with_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ MiniTestLifeCycle

Returns a new instance of MiniTestLifeCycle.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/with_model.rb', line 10

def initialize(object)
  define_method :before_setup do
    object.create
    super() if defined?(super)
  end

  define_method :after_teardown do
    object.destroy
    super() if defined?(super)
  end
end

Class Method Details

.call(object) ⇒ Object



22
23
24
# File 'lib/with_model.rb', line 22

def self.call(object)
  new(object)
end