Sha256: cf9bea59b6e5ce4fc040a7a0d0ff45919214b346a56c198044b9c2f6d1a9b1a7

Contents?: true

Size: 999 Bytes

Versions: 11

Compression:

Stored size: 999 Bytes

Contents

require 'lhc'
class LHC::Config

  def _cleanup
    @endpoints = {}
    @placeholders = {}
    @interceptors = nil
  end
end

class LHS::Record

  CHILDREN = []

  def self.inherited(child)
    CHILDREN.push(child)
    super
  end

end

def reset_lhc
  LHC::Config.instance._cleanup
end

def reset_lhs
  LHS::Record::Endpoints.all = {}
  LHS::Record::CHILDREN.each do |child|
    child.endpoints = [] if !child.name['LHS'] && defined?(child.endpoints)
    child.configuration({}) if !child.name['LHS']
  end
end

RSpec.configure do |config|
  config.before do |spec|
    reset_lhc unless spec.metadata.key?(:reset_before) && spec.metadata[:reset_before] == false
    reset_lhs unless spec.metadata.key?(:reset_before) && spec.metadata[:reset_before] == false
    next unless spec.metadata.key?(:dummy_models) && spec.metadata[:dummy_models] == true
    Dir.glob(Rails.root.join('app', 'models', '**', '*.rb')).each do |file|
      load file if File.read(file).match('LHS::Record')
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lhs-16.1.5 spec/support/reset.rb
lhs-16.1.4 spec/support/reset.rb
lhs-16.1.3 spec/support/reset.rb
lhs-16.1.2 spec/support/reset.rb
lhs-16.1.1 spec/support/reset.rb
lhs-16.1.0 spec/support/reset.rb
lhs-16.0.1 spec/support/reset.rb
lhs-16.0.0 spec/support/reset.rb
lhs-15.7.0 spec/support/reset.rb
lhs-15.6.1 spec/support/reset.rb
lhs-15.6.0 spec/support/reset.rb