Sha256: 491ab941ae0a93ba41f4510776733ca5db675ac5054d7d52fb7aeb38c96b6858

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'itamae'

module Itamae
  describe Resource::RemoteFile do
    let(:runner) do
      double(:runner).tap do |r|
        r.stub(:tmpdir).and_return("/tmp/itamae")
      end
    end
    let(:recipe) do
      double(:recipe).tap do |r|
        r.stub(:runner).and_return(runner)
      end
    end

    subject(:resource) do
      described_class.new(recipe, "name") do
        source "source.file"
        path "/path/to/dst"
      end
    end

    describe "#create_action" do
      it "copies a file" do
        recipe.stub(:path).and_return("/recipe_dir/recipe_file")
        expect(subject).to receive(:send_file).with("/recipe_dir/source.file", %r{^/tmp/itamae/[\d\.]+$})
        expect(subject).to receive(:run_specinfra).with(:check_file_is_file, "/path/to/dst").and_return(true)
        expect(subject).to receive(:run_specinfra).with(:copy_file, "/path/to/dst", "/path/to/dst.bak")
        expect(subject).to receive(:run_specinfra).with(:move_file, %r{/tmp/itamae/[\d\.]+}, "/path/to/dst")
        subject.pre_action
        subject.create_action
      end
    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
itamae-1.0.0.beta11 spec/unit/lib/itamae/resource/remote_file_spec.rb
itamae-1.0.0.beta10 spec/unit/lib/itamae/resource/remote_file_spec.rb
itamae-1.0.0.beta9 spec/unit/lib/itamae/resource/remote_file_spec.rb
itamae-1.0.0.beta8 spec/unit/lib/itamae/resource/remote_file_spec.rb