Sha256: 7879ba392ed4b3b87f808d7570f31afe9ea82e70bb61f8b8052080988e5cdd03

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8

if RUBY_ENGINE == 'rbx'
  require 'codeclimate-test-reporter'
  CodeClimate::TestReporter.start
end

begin
  require 'byebug'
rescue LoadError; end

SPEC_ROOT = Pathname(__FILE__).dirname

Dir[SPEC_ROOT.join('support/*.rb').to_s].each { |f| require f }
Dir[SPEC_ROOT.join('shared/*.rb').to_s].each { |f| require f }

require 'dry/component/container'

class Dry::Component::Container
  setting :env, 'test'
end

module TestNamespace
  def remove_constants
    constants.each do |name|
      remove_const(name)
    end
  end
end

RSpec.configure do |config|
  config.disable_monkey_patching!

  config.before do
    @load_paths = $LOAD_PATH.dup
    @loaded_features = $LOADED_FEATURES.dup
    Object.const_set(:Test, Module.new { |m| m.extend(TestNamespace) })
  end

  config.after do
    ($LOAD_PATH - @load_paths).each do |path|
      $LOAD_PATH.delete(path)
    end
    ($LOADED_FEATURES - @loaded_features).each do |file|
      $LOADED_FEATURES.delete(file)
    end

    Test.remove_constants
    Object.send(:remove_const, :Test)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-component-0.2.0 spec/spec_helper.rb
dry-component-0.1.0 spec/spec_helper.rb