Sha256: 736681d00ebb7b54ea7d00d80bdcfc9d241a837803fb56c85f0a483268d02ead

Contents?: true

Size: 1.29 KB

Versions: 22

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

module Beaker
  describe Unix::Exec do
    class UnixExecTest
      include Unix::Exec

      def initialize(hash, logger)
        @hash = hash
        @logger = logger
      end

      def [](k)
        @hash[k]
      end

      def to_s
        "me"
      end

    end

    let (:opts)     { @opts || {} }
    let (:logger)   { double( 'logger' ).as_null_object }
    let (:instance) { UnixExecTest.new(opts, logger) }

    context "rm" do

      it "deletes" do
        path = '/path/to/delete'
        expect( instance ).to receive(:execute).with("rm -rf #{path}").and_return(0)
        expect( instance.rm_rf(path) ).to be === 0
      end
    end

    context 'mv' do
      let(:origin)      { '/origin/path/of/content' }
      let(:destination) { '/destination/path/of/content' }

      it 'rm first' do
        expect( instance ).to receive(:execute).with("rm -rf #{destination}").and_return(0)
        expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
        expect( instance.mv(origin, destination) ).to be === 0

      end

      it 'does not rm' do
         expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
         expect( instance.mv(origin, destination, false) ).to be === 0
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
beaker-2.30.1 spec/beaker/host/unix/exec_spec.rb
beaker-2.30.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.29.1 spec/beaker/host/unix/exec_spec.rb
beaker-2.29.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.28.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.27.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.26.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.25.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.24.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.23.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.22.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.21.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.20.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.19.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.18.3 spec/beaker/host/unix/exec_spec.rb
beaker-2.18.2 spec/beaker/host/unix/exec_spec.rb
beaker-2.18.1 spec/beaker/host/unix/exec_spec.rb
beaker-2.18.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.17.0 spec/beaker/host/unix/exec_spec.rb
beaker-2.16.0 spec/beaker/host/unix/exec_spec.rb