serverspec 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,8 +20,8 @@ module Serverspec
|
|
20
20
|
cmd = super(cmd)
|
21
21
|
if RSpec.configuration.ssh.options[:user] != 'root'
|
22
22
|
cmd = "sudo #{cmd}"
|
23
|
-
cmd.gsub!(/(\&\&\s
|
24
|
-
cmd.gsub!(/(\|\|\s
|
23
|
+
cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1sudo ")
|
24
|
+
cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1sudo ")
|
25
25
|
end
|
26
26
|
cmd
|
27
27
|
end
|
data/lib/serverspec/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Serverspec::Helper::Ssh
|
4
|
+
|
5
|
+
ssh = double
|
6
|
+
|
7
|
+
|
8
|
+
describe 'build command with sudo' do
|
9
|
+
before :each do
|
10
|
+
RSpec.configure do |c|
|
11
|
+
ssh.stub(:options) { { :user => 'foo' } }
|
12
|
+
c.ssh = ssh
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'command pattern 1' do
|
17
|
+
subject { backend.build_command('test -f /etc/passwd') }
|
18
|
+
it { should eq 'sudo test -f /etc/passwd' }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'command pattern 2' do
|
22
|
+
subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
|
23
|
+
it { should eq 'sudo test ! -f /etc/selinux/config || (sudo getenforce | grep -i -- disabled && sudo grep -i -- ^SELINUX=disabled$ /etc/selinux/config)' }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'command pattern 3' do
|
27
|
+
subject { backend.build_command("dpkg -s apache2 && ! dpkg -s apache2 | grep -E '^Status: .+ not-installed$'") }
|
28
|
+
it { should eq "sudo dpkg -s apache2 && ! sudo dpkg -s apache2 | grep -E '^Status: .+ not-installed$'" }
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/serverspec/version.rb
|
219
219
|
- serverspec.gemspec
|
220
220
|
- spec/backend/exec/configuration_spec.rb
|
221
|
+
- spec/backend/ssh/build_command_spec.rb
|
221
222
|
- spec/backend/ssh/configuration_spec.rb
|
222
223
|
- spec/darwin/command_spec.rb
|
223
224
|
- spec/darwin/cron_spec.rb
|
@@ -348,6 +349,7 @@ specification_version: 3
|
|
348
349
|
summary: RSpec tests for your servers configured by Puppet, Chef or anything else
|
349
350
|
test_files:
|
350
351
|
- spec/backend/exec/configuration_spec.rb
|
352
|
+
- spec/backend/ssh/build_command_spec.rb
|
351
353
|
- spec/backend/ssh/configuration_spec.rb
|
352
354
|
- spec/darwin/command_spec.rb
|
353
355
|
- spec/darwin/cron_spec.rb
|