Sha256: 9ae04eeef618c617d237aa2623e4836a3394d5bb6c1ef72d0f320bb332a6455b

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module NameQ
  describe Directory do
    let(:path) { '/path/to/somewhere' }
    let(:subject) { described_class.new(path) }

    it 'is a kind of pool' do
      expect(subject).to be_a NameQ::Support::Pool
    end

    context 'internals' do
      context 'underlying list' do
        let(:list) { instance_double(NameQ::Support::List) }
        let(:result) { subject.instance_variable_get('@list') }

        it 'builds the right kind of list by default' do
          expect(NameQ::Support::List).to receive(:new).with(case_sensitive: true).and_return list
          expect(result).to eq list
        end

        context 'case-insensitive' do
          let(:subject) { described_class.new(path, case_sensitive: false) }

          it 'builds the right kind of list by default' do
            expect(NameQ::Support::List).to receive(:new).with(case_sensitive: false).and_return list
            expect(result).to eq list
          end
        end

        context 'refresh' do
          let(:path) { File.expand_path('.') }
          let(:items) { result.send(:all) }

          it 'has a block that does the right stuff' do
            expect(items).to include('nameq.gemspec', 'Gemfile', 'Rakefile')
          end
        end
      end

      describe '#entry_factory' do
        it 'has a special filename entry factory' do
          expect(subject.send(:entry_factory)).to eq NameQ::Support::FilenameEntry
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nameq-0.0.1 spec/directory_spec.rb