Sha256: 8c7850f2c8da94439708a8214fa2f74cfa087ef3712e9a5904398a037ec8fde2
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true RSpec.describe Yardcheck::Const do before do stub_const('Foo', Module.new) module Foo module Bar module Baz end # Baz end # Bar end # Foo end it 'resolves top level constant' do expect(described_class.resolve('Foo')).to eql(described_class.new(Foo)) end it 'resolves namespaced constant with qualified top level parent' do expect(described_class.resolve('Foo::Bar')).to eql(described_class.new(Foo::Bar)) end it 'resolves nested constant from nested scope' do expect(described_class.resolve('Bar', Foo)).to eql(described_class.new(Foo::Bar)) end it 'resolves top parent constant from scope of nested constant' do expect(described_class.resolve('Foo', Foo::Bar)).to eql(described_class.new(Foo)) end it 'resolves nested constant form deeply nested scope' do expect(described_class.resolve('Foo::Bar', Foo::Bar::Baz)).to eql(described_class.new(Foo::Bar)) end it 'resolves top level stdlib constant from scope of nested constant' do expect(described_class.resolve('String', Foo::Bar::Baz)).to eql(described_class.new(String)) end it 'resolves the scope when given the scope name' do expect(described_class.resolve('Bar', Foo::Bar)).to eql(described_class.new(Foo::Bar)) end it 'returns an invalid const object when given an unresolveable reference' do expect(described_class.resolve('What', Foo::Bar)).to eql( described_class::Invalid.new(Foo::Bar, 'What') ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yardcheck-0.0.1 | spec/unit/yardcheck/const_spec.rb |