Class: ARLeftOverGuardian::Instance

Inherits:
Object
  • Object
show all
Includes:
CustomContracts, Contracts
Defined in:
lib/ar_left_over_guardian.rb

Overview

Instance of left over guardian, which keeps track of all models counts before test and after test, and expects them to be the same

Constant Summary

Constants included from CustomContracts

CustomContracts::Model

Instance Method Summary collapse

Constructor Details

#initialize(models) ⇒ Instance

Returns a new instance of Instance.


20
21
22
23
24
# File 'lib/ar_left_over_guardian.rb', line 20

def initialize(models)
  @models = models.reject(&method(:abstract?))
  @counts = current_counts(false)
  self
end

Instance Method Details

#verifyObject

Raises:


29
30
31
32
33
34
# File 'lib/ar_left_over_guardian.rb', line 29

def verify
  left_overs = get_left_overs
  return if left_overs.empty?
  model_list = left_overs.map { |model| "- #{model}" }.join("\n")
  raise DidntCleanup.new("Following models has left over records:\n#{model_list}")
end