Sha256: 76cbbd47eee12e1260b555c721ae9791ca3995b51ebd27d3bd4c5d283b5d6891

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

module RevealCK
  module Builders
    describe CopyFilesTask do
      let :source_dir do
        'source'
      end

      let :file_a_source do
        "#{source_dir}/file_a"
      end

      let :file_b_source do
        "#{source_dir}/file_b"
      end

      let :file_listing do
        file_listing = double

        file_listing
          .stub(:files)
          .and_return([file_a_source, file_b_source])

        file_listing
          .stub(:dir)
          .and_return(source_dir)

        file_listing
      end

      let :destination_directory do
        'destination'
      end

      let :file_a_destination do
        "#{destination_directory}/file_a"
      end

      let :file_b_destination do
        "#{destination_directory}/file_b"
      end

      it 'creates the directory from the file_listing' do

        task = CopyFilesTask.new(application: Rake::Application.new,
                                 file_listing: file_listing,
                                 output_dir: destination_directory)
        expect(task)
          .to receive(:create_directory)
          .with(destination_directory)
          .at_least(:once)

        task.prepare
      end

      it 'creates the files from the file_listing' do
        task = CopyFilesTask.new(application: Rake::Application.new,
                                 file_listing: file_listing,
                                 output_dir: destination_directory)

        expect(task)
          .to receive(:copy_file)
          .with(file_a_source, file_a_destination)

        expect(task)
          .to receive(:copy_file)
          .with(file_b_source, file_b_destination)

        task.prepare
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reveal-ck-0.3.0 spec/lib/reveal-ck/builders/copy_files_task_spec.rb