Sha256: 7fa6069be13ff4877072d607d3ecdbf8f74501540ff819c87f327667be9eeade
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true describe Rake::Funnel::Support::Copier do let(:source) { files + directories } let(:files) { %w(bin/1 bin/2 bin/3/4 bin/directory/file) } let(:directories) { %w(bin/directory bin/directory-no-content) } let(:target) { 'target path' } context 'failure' do context 'target not defined' do let(:target) { nil } it 'should fail' do expect { described_class.copy([], nil) }.to raise_error(/Target not defined/) end end end describe 'recursive copy' do before do allow(File).to receive(:directory?).and_return(false) directories.each do |dir| allow(File).to receive(:directory?).with(dir).and_return(true) end allow(RakeFileUtils).to receive(:mkdir_p) allow(RakeFileUtils).to receive(:cp) end before do described_class.copy(source, target) end def no_prefix(file) file.sub(%r{bin/}, '') end it 'should create target directories' do expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(target, '3')) expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(target, 'directory')) end it 'should skip source directories' do directories.each do |dir| expect(RakeFileUtils).not_to have_received(:cp).with(dir, anything) end end it 'should copy files with common path removed' do files.each do |file| target_path = File.join(target, no_prefix(file)) expect(RakeFileUtils).to have_received(:cp).with(file, target_path, anything) end end it 'should preserve metdata' do expect(RakeFileUtils).to have_received(:cp).with(anything, anything, preserve: true).exactly(files.length).times end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rake-funnel-0.24.0 | spec/rake/funnel/support/copier_spec.rb |
rake-funnel-0.23.0 | spec/rake/funnel/support/copier_spec.rb |
rake-funnel-0.22.3 | spec/rake/funnel/support/copier_spec.rb |