Sha256: b872dda84e21bc441de889c76d52361231a5b4e12d7d998f59e2c59906313809

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe MultiSync::LocalSource do
  before do
    FileUtils.mkdir_p('tmp/local-source')
    File.open('tmp/local-source/foo.txt', File::CREAT | File::RDWR) do |f| f.write('foo') end
    File.open('tmp/local-source/bar.txt', File::CREAT | File::RDWR) 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', File::CREAT | File::RDWR) do |f| f.write('baz') end
    File.open('tmp/local-source/in-a-dir/baz.txt', File::CREAT | File::RDWR) 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.4 spec/unit/multi_sync/sources/local_source_spec.rb
multi_sync-0.0.3 spec/unit/multi_sync/sources/local_source_spec.rb