Sha256: 7411760e0de4569a2e35f07d5bd2b8509668e3e2fc5e88a73a322d15ed794b5c

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe MultiSync::LocalSource, fakefs: true do
  before do
    FileUtils.mkdir_p('/tmp/local-source')
    File.open('/tmp/local-source/foo.txt', 'w') do |f| f.write('foo') end
    File.open('/tmp/local-source/bar.txt', 'w') do |f| f.write('bar') end
    FileUtils.mkdir_p('/tmp/local-source/in-a-dir')
    File.open('/tmp/local-source/in-a-dir/baz.html', 'w') do |f| f.write('baz') end
    File.open('/tmp/local-source/in-a-dir/baz.txt', 'w') do |f| f.write('baz') end
  end

  describe :files do
    it 'should find files' do
      source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source')
      expect(source.files).to have(4).files
    end

    it 'should ignore found files' do
      source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source', include: '**/*', exclude: '*/*.html')
      expect(source.files).to have(3).files
    end

    it 'should find files (recursively)' do
      source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source', include: '**/*')
      expect(source.files).to have(4).files
    end

    it 'should find files (by type)' do
      source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source', include: '**/*.txt')
      expect(source.files).to have(3).files
    end

    context :with_root do
      it 'should return files with the root' do
        source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source')
        expect(source.files[0].path_with_root.to_s).to eq '/tmp/local-source/bar.txt'
      end
    end

    context :without_root do
      it 'should return files without the root' do
        source = MultiSync::LocalSource.new(source_dir: '/tmp/local-source')
        expect(source.files[0].path_without_root.to_s).to eq 'bar.txt'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
multi_sync-0.0.2 spec/unit/multi_sync/sources/local_source_spec.rb
multi_sync-0.0.1 spec/unit/multi_sync/sources/local_source_spec.rb