Sha256: ac5c8f2df41c862e1bb4d23d4e5dd0135a1ce5ce931bc002ae1e85ab5eb9e814
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'dry/component/loader' RSpec.describe Dry::Component::Loader do before do module Test class Bar end end end shared_examples_for 'a valid component' do describe '#name' do it 'returns name of the constant' do expect(component.name).to eql('Test::Bar') end end describe '#constant' do it 'returns the constant' do expect(component.constant).to be(Test::Bar) end end describe '#identifier' do it 'returns container identifier' do expect(component.identifier).to eql('test.bar') end end describe '#path' do it 'returns relative path to file defining the component constant' do expect(component.path).to eql('test/bar') end end describe '#file' do it 'returns relative path to file with ext defining the component constant' do expect(component.file).to eql('test/bar.rb') end end describe '#instance' do it 'builds a component class instance' do expect(component.instance).to be_instance_of(Test::Bar) end end end context 'from identifier as a symbol' do subject(:component) { Dry::Component::Loader(:'test.bar') } it_behaves_like 'a valid component' end context 'from identifier as a string' do subject(:component) { Dry::Component::Loader('test.bar') } it_behaves_like 'a valid component' end context 'from path' do subject(:component) { Dry::Component::Loader('test/bar') } it_behaves_like 'a valid component' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-component-0.0.1 | spec/unit/loader_spec.rb |