Sha256: 067064bd971eda74b03175ff5d6aeff9065ba611d3130b2b7a117cb62e9532dd

Contents?: true

Size: 1.01 KB

Versions: 47

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

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

47 entries across 47 versions & 1 rubygems

Version Path
lhs-21.2.2 spec/support/reset.rb
lhs-21.2.1 spec/support/reset.rb
lhs-21.2.0 spec/support/reset.rb
lhs-21.1.4 spec/support/reset.rb
lhs-21.1.3 spec/support/reset.rb
lhs-21.1.2 spec/support/reset.rb
lhs-21.1.2.pre.keyfix.2 spec/support/reset.rb
lhs-21.1.2.pre.keyfix.1 spec/support/reset.rb
lhs-21.1.2.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/support/reset.rb
lhs-21.1.1.pre.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/support/reset.rb
lhs-21.1.0 spec/support/reset.rb
lhs-21.0.0 spec/support/reset.rb
lhs-20.1.4 spec/support/reset.rb
lhs-20.1.3.pre.paginationfix.3 spec/support/reset.rb
lhs-20.1.3.pre.paginationfix.2 spec/support/reset.rb
lhs-20.1.3.pre.paginationfix.1 spec/support/reset.rb
lhs-20.1.2 spec/support/reset.rb
lhs-20.1.1 spec/support/reset.rb
lhs-20.0.0 spec/support/reset.rb
lhs-19.10.0 spec/support/reset.rb