Sha256: f44d96d1e5ccd71b2626541673a0bb2bad1e42f189285a981bf421b3bb9e298c

Contents?: true

Size: 1.55 KB

Versions: 16

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

include Serverspec::Backend::PowerShell::ScriptHelper

describe 'build command with path' do
  before :each do
    RSpec.configure do |c|
      c.path = 'c:/test/path/bin'
    end
  end

  it "should prefix the command with the path instruction" do 
    cmd = build_command('run_script -f param')
    cmd.should eq <<-eof
$env:path = "c:/test/path/bin;$env:path"
run_script -f param
eof
  end

  after :each do
    RSpec.configure do |c|
      c.path = nil
    end
  end
end

describe 'add pre-command' do
  before :each do
    Serverspec.configuration.pre_command = 'test_pre_command'
  end

  it "should add the test for pre_command before the command" do
    cmd = add_pre_command('run_script -f param')
    cmd.should eq <<-eof
if (test_pre_command)
{
run_script -f param
}
eof
  end

  context "with path" do
    before :each do
      RSpec.configure do |c|
        c.path = 'c:/test/path/bin'
      end
    end

  it "should add the path instruction and the test for pre_command before the command" do
    cmd = add_pre_command('run_script -f param')
    cmd.should eq <<-eof
$env:path = "c:/test/path/bin;$env:path"
if (test_pre_command)
{
run_script -f param
}
eof
  end

    after :each do
      RSpec.configure do |c|
        c.path = nil
      end
    end
  end

  after :each do
    Serverspec.configuration.pre_command = nil
  end
end

describe "script encoding" do
  it "should encode the given script" do
    script = encode_script("test_powershell_script")
    script.should == "dABlAHMAdABfAHAAbwB3AGUAcgBzAGgAZQBsAGwAXwBzAGMAcgBpAHAAdAA="
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
serverspec-0.10.6 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.5 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.4 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.3 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.2 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.1 spec/backend/powershell/script_helper_spec.rb
serverspec-0.10.0 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.8 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.7 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.6 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.5 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.4 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.3 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.2 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.1 spec/backend/powershell/script_helper_spec.rb
serverspec-0.9.0 spec/backend/powershell/script_helper_spec.rb