Class: Believer::Test::RSpec::TestRunLifeCycle::Destructor

Inherits:
Observer
  • Object
show all
Defined in:
lib/believer/test/rspec/test_run_life_cycle.rb

Overview

Detroys all CqlRecord::Base instances created

Instance Method Summary collapse

Instance Method Details

#after_save(model) ⇒ Object



42
43
44
# File 'lib/believer/test/rspec/test_run_life_cycle.rb', line 42

def after_save(model)
  saved_models << model
end

#cleanupObject



28
29
30
31
32
33
34
35
36
# File 'lib/believer/test/rspec/test_run_life_cycle.rb', line 28

def cleanup
  saved_models.each do |model|
    begin
      model.destroy
    rescue Exception => e
      puts "Could not destroy model #{model}: #{e}\n#{e.backtrace.join("\n")}"
    end
  end
end

#saved_modelsObject



38
39
40
# File 'lib/believer/test/rspec/test_run_life_cycle.rb', line 38

def saved_models
  @saved_models ||= []
end