Sha256: eb8e73fc148eb9d2bdbf8341b8b1ec11055eb6637eec7d6cb89d39d3bb6ed6db

Contents?: true

Size: 1.46 KB

Versions: 40

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

module Beaker
  describe PSWindows::Exec do
    class PSWindowsExecTest
      include PSWindows::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) { PSWindowsExecTest.new(opts, logger) }

    context "rm" do

      it "deletes" do
        path = '/path/to/delete'
        corrected_path = '\\path\\to\\delete'
        expect( instance ).to receive(:execute).with("del /s /q #{corrected_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("del /s /q #{destination.gsub(/\//, '\\')}").and_return(0)
        expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
        expect( instance.mv(origin, destination) ).to be === 0

      end

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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
beaker-3.17.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.16.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.15.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.14.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.13.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.12.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.11.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.10.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.9.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.8.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.7.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.6.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-2.52.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.5.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.4.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.3.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.2.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.1.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-3.0.0 spec/beaker/host/pswindows/exec_spec.rb
beaker-2.51.0 spec/beaker/host/pswindows/exec_spec.rb