serverspec 0.2.1 → 0.2.2

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.
@@ -94,6 +94,10 @@ module Serverspec
94
94
  def check_iptables_rule(rule, table, chain)
95
95
  check_zero(:check_iptables_rule, rule, table, chain)
96
96
  end
97
+
98
+ def check_zfs(zfs, property)
99
+ check_zero(:check_zfs, zfs, property)
100
+ end
97
101
  end
98
102
  end
99
103
  end
@@ -51,15 +51,15 @@ module Serverspec
51
51
  end
52
52
 
53
53
  def check_mode file, mode
54
- "stat -c %a #{file} | grep #{mode}"
54
+ "stat -c %a #{file} | grep '^#{mode}$'"
55
55
  end
56
56
 
57
57
  def check_owner file, owner
58
- "stat -c %U #{file} | grep #{owner}"
58
+ "stat -c %U #{file} | grep '^#{owner}$'"
59
59
  end
60
60
 
61
61
  def check_grouped file, group
62
- "stat -c %G #{file} | grep #{group}"
62
+ "stat -c %G #{file} | grep '^#{group}$'"
63
63
  end
64
64
 
65
65
  def check_cron_entry user, entry
@@ -88,6 +88,10 @@ module Serverspec
88
88
  cmd += " | grep '#{rule}'"
89
89
  cmd
90
90
  end
91
+
92
+ def check_zfs zfs, property=nil, value=nil
93
+ raise NotImplementedError.new
94
+ end
91
95
  end
92
96
  end
93
97
  end
@@ -22,6 +22,17 @@ module Serverspec
22
22
  "crontab -l #{user} | grep '#{entry_escaped}'"
23
23
  end
24
24
 
25
+ def check_zfs zfs, property=nil
26
+ if property.nil?
27
+ "/sbin/zfs list -H #{zfs}"
28
+ else
29
+ commands = []
30
+ property.sort.each do |key, value|
31
+ commands << "/sbin/zfs list -H -o #{key} #{zfs} | grep ^#{value}$"
32
+ end
33
+ commands.join(' && ')
34
+ end
35
+ end
25
36
  end
26
37
  end
27
38
  end
@@ -16,3 +16,4 @@ require 'serverspec/matchers/be_installed_by_gem'
16
16
  require 'serverspec/matchers/belong_to_group'
17
17
  require 'serverspec/matchers/have_iptables_rule'
18
18
  require 'serverspec/matchers/get_stdout'
19
+ require 'serverspec/matchers/be_zfs'
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :be_zfs do
2
+ match do |zfs|
3
+ backend.check_zfs(zfs, @property)
4
+ end
5
+
6
+ chain :with do |property|
7
+ @property = property
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -59,15 +59,15 @@ describe commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test d
59
59
  end
60
60
 
61
61
  describe commands.check_mode('/etc/sudoers', 440) do
62
- it { should eq 'stat -c %a /etc/sudoers | grep 440' }
62
+ it { should eq 'stat -c %a /etc/sudoers | grep \'^440$\'' }
63
63
  end
64
64
 
65
65
  describe commands.check_owner('/etc/passwd', 'root') do
66
- it { should eq 'stat -c %U /etc/passwd | grep root' }
66
+ it { should eq 'stat -c %U /etc/passwd | grep \'^root$\'' }
67
67
  end
68
68
 
69
69
  describe commands.check_grouped('/etc/passwd', 'wheel') do
70
- it { should eq 'stat -c %G /etc/passwd | grep wheel' }
70
+ it { should eq 'stat -c %G /etc/passwd | grep \'^wheel$\'' }
71
71
  end
72
72
 
73
73
  describe commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') do
@@ -59,15 +59,15 @@ describe commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test d
59
59
  end
60
60
 
61
61
  describe commands.check_mode('/etc/sudoers', 440) do
62
- it { should eq 'stat -c %a /etc/sudoers | grep 440' }
62
+ it { should eq 'stat -c %a /etc/sudoers | grep \'^440$\'' }
63
63
  end
64
64
 
65
65
  describe commands.check_owner('/etc/passwd', 'root') do
66
- it { should eq 'stat -c %U /etc/passwd | grep root' }
66
+ it { should eq 'stat -c %U /etc/passwd | grep \'^root$\'' }
67
67
  end
68
68
 
69
69
  describe commands.check_grouped('/etc/passwd', 'wheel') do
70
- it { should eq 'stat -c %G /etc/passwd | grep wheel' }
70
+ it { should eq 'stat -c %G /etc/passwd | grep \'^wheel$\'' }
71
71
  end
72
72
 
73
73
  describe commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') do
@@ -59,15 +59,15 @@ describe commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test d
59
59
  end
60
60
 
61
61
  describe commands.check_mode('/etc/sudoers', 440) do
62
- it { should eq 'stat -c %a /etc/sudoers | grep 440' }
62
+ it { should eq 'stat -c %a /etc/sudoers | grep \'^440$\'' }
63
63
  end
64
64
 
65
65
  describe commands.check_owner('/etc/passwd', 'root') do
66
- it { should eq 'stat -c %U /etc/passwd | grep root' }
66
+ it { should eq 'stat -c %U /etc/passwd | grep \'^root$\'' }
67
67
  end
68
68
 
69
69
  describe commands.check_grouped('/etc/passwd', 'wheel') do
70
- it { should eq 'stat -c %G /etc/passwd | grep wheel' }
70
+ it { should eq 'stat -c %G /etc/passwd | grep \'^wheel$\'' }
71
71
  end
72
72
 
73
73
  describe commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') do
@@ -59,15 +59,15 @@ describe commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test d
59
59
  end
60
60
 
61
61
  describe commands.check_mode('/etc/sudoers', 440) do
62
- it { should eq 'stat -c %a /etc/sudoers | grep 440' }
62
+ it { should eq 'stat -c %a /etc/sudoers | grep \'^440$\'' }
63
63
  end
64
64
 
65
65
  describe commands.check_owner('/etc/passwd', 'root') do
66
- it { should eq 'stat -c %U /etc/passwd | grep root' }
66
+ it { should eq 'stat -c %U /etc/passwd | grep \'^root$\'' }
67
67
  end
68
68
 
69
69
  describe commands.check_grouped('/etc/passwd', 'wheel') do
70
- it { should eq 'stat -c %G /etc/passwd | grep wheel' }
70
+ it { should eq 'stat -c %G /etc/passwd | grep \'^wheel$\'' }
71
71
  end
72
72
 
73
73
  describe commands.check_cron_entry('root', '* * * * * /usr/local/bin/batch.sh') do
@@ -85,3 +85,24 @@ end
85
85
  describe commands.check_belonging_group('root', 'wheel') do
86
86
  it { should eq "id root | awk '{print $2}' | grep wheel" }
87
87
  end
88
+
89
+ describe commands.check_zfs('rpool') do
90
+ it { should eq "/sbin/zfs list -H rpool" }
91
+ end
92
+
93
+ describe commands.check_zfs('rpool', { 'mountpoint' => '/rpool' }) do
94
+ it { should eq "/sbin/zfs list -H -o mountpoint rpool | grep ^/rpool$" }
95
+ end
96
+
97
+ describe commands.check_zfs('rpool', { 'mountpoint' => '/rpool' }) do
98
+ it { should eq "/sbin/zfs list -H -o mountpoint rpool | grep ^/rpool$" }
99
+ end
100
+
101
+ check_zfs_with_multiple_properties = commands.check_zfs('rpool', {
102
+ 'mountpoint' => '/rpool',
103
+ 'compression' => 'off',
104
+ })
105
+
106
+ describe check_zfs_with_multiple_properties do
107
+ it { should eq "/sbin/zfs list -H -o compression rpool | grep ^off$ && /sbin/zfs list -H -o mountpoint rpool | grep ^/rpool$" }
108
+ end
@@ -33,4 +33,6 @@ describe 'Serverspec matchers of Solaris family', :os => :solaris do
33
33
  it_behaves_like 'support belong_to_group matcher', 'root', 'root'
34
34
 
35
35
  it_behaves_like 'support get_stdout matcher', 'whoami', 'root'
36
+ it_behaves_like 'support be_zfs matcher', 'rpool'
37
+ it_behaves_like 'support be_zfs.property matcher', 'rpool', { 'mountpoint' => '/rpool' }
36
38
  end
@@ -305,3 +305,27 @@ shared_examples_for 'support get_stdout matcher' do |command, output|
305
305
  it { should_not get_stdout 'invalid-output' }
306
306
  end
307
307
  end
308
+
309
+ shared_examples_for 'support be_zfs matcher' do |zfs|
310
+ describe 'be_zfs' do
311
+ describe zfs do
312
+ it { should be_zfs }
313
+ end
314
+
315
+ describe 'this-is-invalid-zfs' do
316
+ it { should_not be_zfs }
317
+ end
318
+ end
319
+ end
320
+
321
+ shared_examples_for 'support be_zfs.property matcher' do |zfs, property|
322
+ describe 'be_zfs' do
323
+ describe zfs do
324
+ it { should be_zfs.with(property) }
325
+ end
326
+
327
+ describe 'this-is-invalid-zfs' do
328
+ it { should_not be_zfs.with(property) }
329
+ end
330
+ end
331
+ end
metadata CHANGED
@@ -1,90 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gosuke Miyashita
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-04-08 00:00:00 +09:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: net-ssh
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bundler
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
- requirements:
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
41
35
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 9
44
- segments:
45
- - 1
46
- - 3
47
- version: "1.3"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
48
38
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rspec
52
39
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
54
49
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
62
54
  type: :development
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: rake
66
55
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
68
57
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
76
70
  type: :development
77
- version_requirements: *id004
78
- description: RSpec tests for your servers provisioned by Puppet, Chef or anything else
79
- email:
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: RSpec tests for your servers provisioned by Puppet, Chef or anything
79
+ else
80
+ email:
80
81
  - gosukenator@gmail.com
81
- executables:
82
+ executables:
82
83
  - serverspec-init
83
84
  extensions: []
84
-
85
85
  extra_rdoc_files: []
86
-
87
- files:
86
+ files:
88
87
  - .gitignore
89
88
  - .travis.yml
90
89
  - Gemfile
@@ -125,6 +124,7 @@ files:
125
124
  - lib/serverspec/matchers/be_owned_by.rb
126
125
  - lib/serverspec/matchers/be_running.rb
127
126
  - lib/serverspec/matchers/be_user.rb
127
+ - lib/serverspec/matchers/be_zfs.rb
128
128
  - lib/serverspec/matchers/belong_to_group.rb
129
129
  - lib/serverspec/matchers/contain.rb
130
130
  - lib/serverspec/matchers/get_stdout.rb
@@ -143,41 +143,32 @@ files:
143
143
  - spec/solaris/matchers_spec.rb
144
144
  - spec/spec_helper.rb
145
145
  - spec/support/shared_matcher_examples.rb
146
- has_rdoc: true
147
146
  homepage: http://serverspec.org/
148
- licenses:
147
+ licenses:
149
148
  - MIT
150
149
  post_install_message:
151
150
  rdoc_options: []
152
-
153
- require_paths:
151
+ require_paths:
154
152
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
153
+ required_ruby_version: !ruby/object:Gem::Requirement
156
154
  none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- hash: 3
161
- segments:
162
- - 0
163
- version: "0"
164
- required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
160
  none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
173
165
  requirements: []
174
-
175
166
  rubyforge_project:
176
- rubygems_version: 1.3.7
167
+ rubygems_version: 1.8.23
177
168
  signing_key:
178
169
  specification_version: 3
179
170
  summary: RSpec tests for your servers provisioned by Puppet, Chef or anything else
180
- test_files:
171
+ test_files:
181
172
  - spec/debian/commands_spec.rb
182
173
  - spec/debian/matchers_spec.rb
183
174
  - spec/gentoo/commands_spec.rb