Sha256: 01df0e9d5c743201b8b5e0b59e9cc748aa18c279a21695a2cdd384000cf7ef10

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

if ENV['COVERAGE'] == 'true' && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.3.1'
  require "simplecov"
  SimpleCov.start do
    add_filter '/spec/'
  end
end

begin
  require 'pry'
  require 'pry-byebug'
rescue LoadError
end

require 'dry-validation'
require 'dry/core/constants'
require 'ostruct'

SPEC_ROOT = Pathname(__dir__)

Dir[SPEC_ROOT.join('shared/**/*.rb')].each(&method(:require))
Dir[SPEC_ROOT.join('support/**/*.rb')].each(&method(:require))

include Dry::Validation

module Types
  include Dry::Types.module
end

Dry::Validation::Deprecations.configure do |config|
  config.logger = Logger.new(SPEC_ROOT.join('../log/deprecations.log'))
end

RSpec.configure do |config|
  config.disable_monkey_patching!
  config.warnings = true

  config.after do
    if defined?(I18n)
      I18n.load_path = Dry::Validation.messages_paths.dup
      I18n.backend.reload!
    end
  end

  config.include PredicatesIntegration

  config.before do
    module Test
      def self.remove_constants
        constants.each { |const| remove_const(const)  }
        self
      end
    end

    Dry::Validation::Messages::Abstract.instance_variable_set('@cache', nil)
    Dry::Validation::Messages::YAML.instance_variable_set('@cache', nil)
    Dry::Validation::Messages::I18n.instance_variable_set('@cache', nil) if defined?(I18n)
  end

  config.after do
    Object.send(:remove_const, Test.remove_constants.name)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-0.13.3 spec/spec_helper.rb
dry-validation-0.13.2 spec/spec_helper.rb