Sha256: 6b033e8a56c599f7599afb62b96eaa854a0247877fe3570518fbd086659f79ea

Contents?: true

Size: 1.17 KB

Versions: 46

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

include SpecInfra::Helper::Exec

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

  context 'command pattern 1' do
    subject { backend.build_command('test -f /etc/passwd') }
    it { should eq 'env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
  end

  context 'command pattern 2' do
    subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
      it { should eq 'env PATH=/sbin:/usr/sbin:$PATH test ! -f /etc/selinux/config || (env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- disabled && env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=disabled$ /etc/selinux/config)' }
  end

  context 'command pattern 3' do
    subject { backend.build_command("dpkg -s apache2 && ! dpkg -s apache2 | grep -E '^Status: .+ not-installed$'") }
    it { should eq "env PATH=/sbin:/usr/sbin:$PATH dpkg -s apache2 && ! env PATH=/sbin:/usr/sbin:$PATH dpkg -s apache2 | grep -E '^Status: .+ not-installed$'" }
  end

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

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
serverspec-0.13.4 spec/backend/exec/build_command_spec.rb
serverspec-0.13.3 spec/backend/exec/build_command_spec.rb
serverspec-0.13.2 spec/backend/exec/build_command_spec.rb
serverspec-0.13.1 spec/backend/exec/build_command_spec.rb
serverspec-0.13.0 spec/backend/exec/build_command_spec.rb
serverspec-0.12.0 spec/backend/exec/build_command_spec.rb