serverspec 0.4.8 → 0.4.9
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.
- data/README.md +8 -9
- data/lib/serverspec/backend/exec.rb +0 -10
- data/lib/serverspec/commands/base.rb +6 -3
- data/lib/serverspec/matchers/be_installed.rb +1 -1
- data/lib/serverspec/type/package.rb +1 -1
- data/lib/serverspec/version.rb +1 -1
- data/spec/darwin/commands_spec.rb +5 -5
- data/spec/debian/commands_spec.rb +5 -5
- data/spec/gentoo/commands_spec.rb +5 -5
- data/spec/redhat/commands_spec.rb +5 -5
- data/spec/solaris/commands_spec.rb +5 -5
- data/spec/support/shared_commands_examples.rb +13 -0
- data/spec/support/shared_matcher_examples.rb +0 -6
- data/spec/support/shared_package_examples.rb +0 -6
- metadata +4 -2
data/README.md
CHANGED
@@ -47,13 +47,13 @@ spec/www.example.jp/httpd_spec.rb is a sample spec file and its content is like
|
|
47
47
|
```ruby
|
48
48
|
require 'spec_helper'
|
49
49
|
|
50
|
-
describe package('httpd)
|
50
|
+
describe package('httpd') do
|
51
51
|
it { should be_installed }
|
52
52
|
end
|
53
53
|
|
54
54
|
describe service('httpd') do
|
55
|
-
it { should be_enabled
|
56
|
-
it { should be_running
|
55
|
+
it { should be_enabled }
|
56
|
+
it { should be_running }
|
57
57
|
end
|
58
58
|
|
59
59
|
describe port(80) do
|
@@ -88,7 +88,7 @@ Finished in 0.99715 seconds
|
|
88
88
|
----
|
89
89
|
## Multi OS support
|
90
90
|
|
91
|
-
Serverspec is supporting Red Hat based OS, Debian based OS, Gentoo and Solaris.
|
91
|
+
Serverspec is supporting Darwin based OS, Red Hat based OS, Debian based OS, Gentoo and Solaris.
|
92
92
|
|
93
93
|
Serverspec can detect target host's OS automatically.
|
94
94
|
|
@@ -100,11 +100,10 @@ require 'serverspec'
|
|
100
100
|
require 'pathname'
|
101
101
|
require 'net/ssh'
|
102
102
|
|
103
|
+
include Serverspec::Helper::Ssh
|
104
|
+
include Serverspec::Helper::Debian
|
105
|
+
|
103
106
|
RSpec.configure do |c|
|
104
|
-
# Include backend helper
|
105
|
-
c.include(Serverspec::Helper::Ssh)
|
106
|
-
# Include OS helper
|
107
|
-
c.include(Serverspec::Helper::Debian)
|
108
107
|
# Add SSH before hook in case you use the SSH backend
|
109
108
|
# (not required for the Exec backend)
|
110
109
|
c.before do
|
@@ -120,7 +119,7 @@ RSpec.configure do |c|
|
|
120
119
|
end
|
121
120
|
```
|
122
121
|
|
123
|
-
You can select **Serverspec::Helper::RedHat**, **Serverspec::Helper::Debian**, **Serverspec::Helper::Gentoo** or **Serverspec::Helper::
|
122
|
+
You can select **Serverspec::Helper::RedHat**, **Serverspec::Helper::Debian**, **Serverspec::Helper::Gentoo** , **Serverspec::Helper::Solaris** or **Serverspec::Helper::Darwin**.
|
124
123
|
|
125
124
|
See details on [serverspec.org](http://serverspec.org)
|
126
125
|
|
@@ -35,16 +35,6 @@ module Serverspec
|
|
35
35
|
check_zero(meth, *args)
|
36
36
|
end
|
37
37
|
|
38
|
-
def check_installed_by_gem(example, package, version)
|
39
|
-
@example = example
|
40
|
-
ret = run_command(commands.check_installed_by_gem(package))
|
41
|
-
res = ret[:exit_status] == 0
|
42
|
-
if res && version
|
43
|
-
res = false if not ret[:stdout].match(/\(#{version}\)/)
|
44
|
-
end
|
45
|
-
res
|
46
|
-
end
|
47
|
-
|
48
38
|
def check_running(example, process)
|
49
39
|
@example = example
|
50
40
|
ret = run_command(commands.check_running(process))
|
@@ -120,9 +120,12 @@ module Serverspec
|
|
120
120
|
"stat -c %N #{escape(link)} | grep -- #{escape(target)}"
|
121
121
|
end
|
122
122
|
|
123
|
-
def check_installed_by_gem name
|
124
|
-
|
125
|
-
|
123
|
+
def check_installed_by_gem name, version=nil
|
124
|
+
cmd = "gem list --local | grep -w -- ^#{escape(name)}"
|
125
|
+
if ! version.nil?
|
126
|
+
cmd = "#{cmd} | grep -w -- #{escape(version)}"
|
127
|
+
end
|
128
|
+
cmd
|
126
129
|
end
|
127
130
|
|
128
131
|
def check_belonging_group user, group
|
@@ -8,7 +8,7 @@ RSpec::Matchers.define :be_installed do
|
|
8
8
|
else
|
9
9
|
check_method = "check_installed_by_#{@provider}".to_sym
|
10
10
|
|
11
|
-
unless backend.respond_to?(check_method)
|
11
|
+
unless backend.respond_to?(check_method) || commands.respond_to?(check_method)
|
12
12
|
raise ArgumentError.new("`be_installed` matcher doesn't support #{@under}")
|
13
13
|
end
|
14
14
|
|
@@ -7,7 +7,7 @@ module Serverspec
|
|
7
7
|
else
|
8
8
|
check_method = "check_installed_by_#{provider}".to_sym
|
9
9
|
|
10
|
-
unless backend.respond_to?(check_method)
|
10
|
+
unless backend.respond_to?(check_method) || commands.respond_to?(check_method)
|
11
11
|
raise ArgumentError.new("`be_installed` matcher doesn't support #{provider}")
|
12
12
|
end
|
13
13
|
|
data/lib/serverspec/version.rb
CHANGED
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Darwin
|
4
4
|
|
5
|
+
describe 'Serverspec commands of Darwin family' do
|
6
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll'
|
7
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll', '1.0.2'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe 'check_file' do
|
6
11
|
subject { commands.check_file('/etc/passwd') }
|
7
12
|
it { should eq 'test -f /etc/passwd' }
|
@@ -146,11 +151,6 @@ describe 'check_link' do
|
|
146
151
|
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/darwin-release' }
|
147
152
|
end
|
148
153
|
|
149
|
-
describe 'check_installed_by_gem' do
|
150
|
-
subject { commands.check_installed_by_gem('jekyll') }
|
151
|
-
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
152
|
-
end
|
153
|
-
|
154
154
|
describe 'check_belonging_group' do
|
155
155
|
subject { commands.check_belonging_group('root', 'wheel') }
|
156
156
|
it { should eq "id root | awk '{print $3}' | grep -- wheel" }
|
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Debian
|
4
4
|
|
5
|
+
describe 'Serverspec commands of Debian family' do
|
6
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll'
|
7
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll', '1.0.2'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe 'check_enabled' do
|
6
11
|
subject { commands.check_enabled('httpd') }
|
7
12
|
it { should eq 'ls /etc/rc3.d/ | grep -- httpd' }
|
@@ -158,11 +163,6 @@ describe 'check_link' do
|
|
158
163
|
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/redhat-release' }
|
159
164
|
end
|
160
165
|
|
161
|
-
describe 'check_installed_by_gem' do
|
162
|
-
subject { commands.check_installed_by_gem('jekyll') }
|
163
|
-
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
164
|
-
end
|
165
|
-
|
166
166
|
describe 'check_belonging_group' do
|
167
167
|
subject { commands.check_belonging_group('root', 'wheel') }
|
168
168
|
it { should eq "id root | awk '{print $3}' | grep -- wheel" }
|
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Gentoo
|
4
4
|
|
5
|
+
describe 'Serverspec commands of Gentoo family' do
|
6
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll'
|
7
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll', '1.0.2'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe 'check_enabled' do
|
6
11
|
subject { commands.check_enabled('httpd') }
|
7
12
|
it { should eq "/sbin/rc-update show | grep -- \\^\\\\s\\*httpd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" }
|
@@ -156,11 +161,6 @@ describe 'check_link' do
|
|
156
161
|
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/redhat-release' }
|
157
162
|
end
|
158
163
|
|
159
|
-
describe 'check_installed_by_gem' do
|
160
|
-
subject { commands.check_installed_by_gem('jekyll') }
|
161
|
-
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
162
|
-
end
|
163
|
-
|
164
164
|
describe 'check_belonging_group' do
|
165
165
|
subject { commands.check_belonging_group('root', 'wheel') }
|
166
166
|
it { should eq "id root | awk '{print $3}' | grep -- wheel" }
|
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::RedHat
|
4
4
|
|
5
|
+
describe 'Serverspec commands of Red Hat' do
|
6
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll'
|
7
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll', '1.0.2'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe 'check_enabled' do
|
6
11
|
subject { commands.check_enabled('httpd') }
|
7
12
|
it { should eq '/sbin/chkconfig --list httpd | grep 3:on' }
|
@@ -156,11 +161,6 @@ describe 'check_link' do
|
|
156
161
|
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/redhat-release' }
|
157
162
|
end
|
158
163
|
|
159
|
-
describe 'check_installed_by_gem' do
|
160
|
-
subject { commands.check_installed_by_gem('jekyll') }
|
161
|
-
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
162
|
-
end
|
163
|
-
|
164
164
|
describe 'check_belonging_group' do
|
165
165
|
subject { commands.check_belonging_group('root', 'wheel') }
|
166
166
|
it { should eq "id root | awk '{print $3}' | grep -- wheel" }
|
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Serverspec::Helper::Solaris
|
4
4
|
|
5
|
+
describe 'Serverspec commands of Solaris family' do
|
6
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll'
|
7
|
+
it_behaves_like 'support command check_installed_by_gem', 'jekyll', '1.0.2'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe 'check_enabled' do
|
6
11
|
subject { commands.check_enabled('httpd') }
|
7
12
|
it { should eq "svcs -l httpd 2> /dev/null | grep 'enabled true'" }
|
@@ -156,11 +161,6 @@ describe 'check_link' do
|
|
156
161
|
it { should eq 'stat -c %N /etc/system-release | grep -- /etc/redhat-release' }
|
157
162
|
end
|
158
163
|
|
159
|
-
describe 'check_installed_by_gem' do
|
160
|
-
subject { commands.check_installed_by_gem('jekyll') }
|
161
|
-
it { should eq 'gem list --local | grep -- \\^jekyll\\ ' }
|
162
|
-
end
|
163
|
-
|
164
164
|
describe 'check_belonging_group' do
|
165
165
|
subject { commands.check_belonging_group('root', 'wheel') }
|
166
166
|
it { should eq "id -Gn root | grep -- wheel" }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
shared_examples_for 'support command check_installed_by_gem' do |package|
|
2
|
+
describe 'check_installed_by_gem' do
|
3
|
+
subject { commands.check_installed_by_gem(package) }
|
4
|
+
it { should eq "gem list --local | grep -w -- ^#{package}" }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
shared_examples_for 'support command check_installed_by_gem with_version' do |package, version|
|
9
|
+
describe 'check_installed_by_gem with_version' do |package, version|
|
10
|
+
subject { commands.check_installed_by_gem(package) }
|
11
|
+
it { should eq "gem list --local | grep -w -- ^#{package} | grep -w -- ^#{version}" }
|
12
|
+
end
|
13
|
+
end
|
@@ -643,12 +643,6 @@ end
|
|
643
643
|
|
644
644
|
shared_examples_for 'support be_installed.by(gem).with_version matcher' do |name, version|
|
645
645
|
describe 'be_installed.by(gem).with_version' do
|
646
|
-
before :all do
|
647
|
-
RSpec.configure do |c|
|
648
|
-
c.stdout = "#{name} (#{version})"
|
649
|
-
end
|
650
|
-
end
|
651
|
-
|
652
646
|
describe name do
|
653
647
|
it { should be_installed.by('gem').with_version(version) }
|
654
648
|
end
|
@@ -24,12 +24,6 @@ end
|
|
24
24
|
|
25
25
|
shared_examples_for 'support package installed by gem with version matcher' do |name, version|
|
26
26
|
describe 'installed by gem with version' do
|
27
|
-
before :all do
|
28
|
-
RSpec.configure do |c|
|
29
|
-
c.stdout = "#{name} (#{version})"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
27
|
describe package(name) do
|
34
28
|
it { should be_installed.by('gem').with_version(version) }
|
35
29
|
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.4.
|
4
|
+
version: 0.4.9
|
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-05-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -313,6 +313,7 @@ files:
|
|
313
313
|
- spec/solaris/zfs_spec.rb
|
314
314
|
- spec/spec_helper.rb
|
315
315
|
- spec/support/shared_command_examples.rb
|
316
|
+
- spec/support/shared_commands_examples.rb
|
316
317
|
- spec/support/shared_cron_examples.rb
|
317
318
|
- spec/support/shared_default_gateway_examples.rb
|
318
319
|
- spec/support/shared_file_examples.rb
|
@@ -433,6 +434,7 @@ test_files:
|
|
433
434
|
- spec/solaris/zfs_spec.rb
|
434
435
|
- spec/spec_helper.rb
|
435
436
|
- spec/support/shared_command_examples.rb
|
437
|
+
- spec/support/shared_commands_examples.rb
|
436
438
|
- spec/support/shared_cron_examples.rb
|
437
439
|
- spec/support/shared_default_gateway_examples.rb
|
438
440
|
- spec/support/shared_file_examples.rb
|