Sha256: 8a4c6ec5d6dea13e1de7d9c8ff32aee7103af7b6d03714b3e81e9ced8a0f75c5
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
RSpec.describe 'Dry::Importer' do before do module Test module BaseLibrary VERSION = '0.1.0' module Tools EMPTY_ARRAY = [].freeze class SomeClass; end class FirstTool def self.empty_array EMPTY_ARRAY end end class SecondTool def self.some_class namespace::SomeClass.new end private def self.namespace Module.const_get(self.to_s[/(.*)(?=::)/]) end end end end module ExtensionLibrary Dry::Importer.import(self, Test::BaseLibrary) end end end it 'imports a constant tree into another' do expect(Test::ExtensionLibrary).to have_constant(:VERSION) expect(Test::ExtensionLibrary).to have_constant(:Tools) expect(Test::ExtensionLibrary::Tools).to have_constant(:EMPTY_ARRAY) expect(Test::ExtensionLibrary::Tools).to have_constant(:SomeClass) expect(Test::ExtensionLibrary::Tools).to have_constant(:FirstTool) expect(Test::ExtensionLibrary::Tools).to have_constant(:SecondTool) expect(Test::ExtensionLibrary::VERSION).to eq('0.1.0') expect(Test::ExtensionLibrary::Tools::EMPTY_ARRAY).to eq([]) expect(Test::ExtensionLibrary::Tools::EMPTY_ARRAY).to be_frozen expect(Test::ExtensionLibrary::Tools::FirstTool.empty_array).to eq([]) expect(Test::ExtensionLibrary::Tools::SecondTool.some_class).to be_a( Test::ExtensionLibrary::Tools::SomeClass ) end it 'does not mutate original namespace' do Test::ExtensionLibrary::VERSION = '0.2.0' expect(Test::BaseLibrary::VERSION).to eq('0.1.0') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-importer-0.0.1 | spec/integration/importer_spec.rb |