serverspec 0.2.19 → 0.2.20

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Serverspec [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.png)](http://travis-ci.org/mizzy/serverspec)
1
+ # Serverspec [![Gem Version](https://badge.fury.io/rb/serverspec.png)](http://badge.fury.io/rb/serverspec) [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.png)](http://travis-ci.org/mizzy/serverspec)
2
2
 
3
3
  RSpec tests for your servers provisioned by Puppet, Chef or anything else
4
4
 
@@ -11,7 +11,7 @@ module Serverspec
11
11
  @commands
12
12
  end
13
13
 
14
- def do_check(cmd, opts={})
14
+ def run_command(cmd, opts={})
15
15
  # In ruby 1.9, it is possible to use Open3.capture3, but not in 1.8
16
16
  #stdout, stderr, status = Open3.capture3(cmd)
17
17
  # So get exit status with `command`
@@ -26,7 +26,7 @@ module Serverspec
26
26
  end
27
27
 
28
28
  def check_zero(cmd, *args)
29
- ret = do_check(commands.send(cmd, *args))
29
+ ret = run_command(commands.send(cmd, *args))
30
30
  ret[:exit_status] == 0
31
31
  end
32
32
 
@@ -38,7 +38,7 @@ module Serverspec
38
38
  end
39
39
 
40
40
  def check_installed_by_gem(example, package, version)
41
- ret = do_check(commands.check_installed_by_gem(package))
41
+ ret = run_command(commands.check_installed_by_gem(package))
42
42
  res = ret[:exit_status] == 0
43
43
  if res && version
44
44
  res = false if not ret[:stdout].match(/\(#{version}\)/)
@@ -47,20 +47,20 @@ module Serverspec
47
47
  end
48
48
 
49
49
  def check_running(example, process)
50
- ret = do_check(commands.check_running(process))
50
+ ret = run_command(commands.check_running(process))
51
51
  if ret[:exit_status] == 1 || ret[:stdout] =~ /stopped/
52
- ret = do_check(commands.check_process(process))
52
+ ret = run_command(commands.check_process(process))
53
53
  end
54
54
  ret[:exit_status] == 0
55
55
  end
56
56
 
57
57
  def check_running_under_supervisor(example, process)
58
- ret = do_check(commands.check_running_under_supervisor(process))
58
+ ret = run_command(commands.check_running_under_supervisor(process))
59
59
  ret[:exit_status] == 0 && ret[:stdout] =~ /RUNNING/
60
60
  end
61
61
 
62
62
  def check_readable(example, file, by_whom)
63
- mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
63
+ mode = sprintf('%04s',run_command(commands.get_mode(file))[:stdout].strip)
64
64
  mode = mode.split('')
65
65
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
66
66
  case by_whom
@@ -76,7 +76,7 @@ module Serverspec
76
76
  end
77
77
 
78
78
  def check_writable(example, file, by_whom)
79
- mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
79
+ mode = sprintf('%04s',run_command(commands.get_mode(file))[:stdout].strip)
80
80
  mode = mode.split('')
81
81
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
82
82
  case by_whom
@@ -92,7 +92,7 @@ module Serverspec
92
92
  end
93
93
 
94
94
  def check_executable(example, file, by_whom)
95
- mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
95
+ mode = sprintf('%04s',run_command(commands.get_mode(file))[:stdout].strip)
96
96
  mode = mode.split('')
97
97
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
98
98
  case by_whom
@@ -107,14 +107,48 @@ module Serverspec
107
107
  end
108
108
  end
109
109
 
110
+ def check_mounted(example, path, expected_attr, only_with)
111
+ ret = run_command(commands.check_mounted(path))
112
+ if expected_attr.nil? || ret[:exit_status] != 0
113
+ return ret[:exit_status] == 0
114
+ end
115
+
116
+ mount = ret[:stdout].scan(/\S+/)
117
+ actual_attr = { :device => mount[0], :type => mount[4] }
118
+ mount[5].gsub(/\(|\)/, '').split(',').each do |option|
119
+ name, val = option.split('=')
120
+ if val.nil?
121
+ actual_attr[name.to_sym] = true
122
+ else
123
+ val = val.to_i if val.match(/^\d+$/)
124
+ actual_attr[name.to_sym] = val
125
+ end
126
+ end
127
+
128
+ if ! expected_attr[:options].nil?
129
+ expected_attr.merge!(expected_attr[:options])
130
+ expected_attr.delete(:options)
131
+ end
132
+
133
+ if only_with
134
+ actual_attr == expected_attr
135
+ else
136
+ match = true
137
+ expected_attr.each do |key, val|
138
+ match = actual_attr[key] == val
139
+ end
140
+ match
141
+ end
142
+ end
143
+
110
144
  def check_os
111
- if do_check('ls /etc/redhat-release')[:exit_status] == 0
145
+ if run_command('ls /etc/redhat-release')[:exit_status] == 0
112
146
  'RedHat'
113
- elsif do_check('ls /etc/debian_version')[:exit_status] == 0
147
+ elsif run_command('ls /etc/debian_version')[:exit_status] == 0
114
148
  'Debian'
115
- elsif do_check('ls /etc/gentoo-release')[:exit_status] == 0
149
+ elsif run_command('ls /etc/gentoo-release')[:exit_status] == 0
116
150
  'Gentoo'
117
- elsif do_check('uname -s')[:stdout] =~ /SunOS/i
151
+ elsif run_command('uname -s')[:stdout] =~ /SunOS/i
118
152
  'Solaris'
119
153
  end
120
154
  end
@@ -3,7 +3,7 @@ require 'serverspec/backend/exec'
3
3
  module Serverspec
4
4
  module Backend
5
5
  class Ssh < Exec
6
- def do_check(cmd, opt={})
6
+ def run_command(cmd, opt={})
7
7
  cmd = "sudo #{cmd}" if not RSpec.configuration.ssh.options[:user] == 'root'
8
8
  ssh_exec!(cmd)
9
9
  end
@@ -7,6 +7,20 @@ module Serverspec
7
7
  raise NotImplementedError.new
8
8
  end
9
9
 
10
+ def check_mounted path
11
+ "mount | grep -w 'on #{path}'"
12
+ end
13
+
14
+ def check_resolvable name, type
15
+ if type == "dns"
16
+ "nslookup -timeout=1 #{name}"
17
+ elsif type == "hosts"
18
+ "grep -w #{name} /etc/hosts"
19
+ else
20
+ "getent hosts #{name}"
21
+ end
22
+ end
23
+
10
24
  def check_file file
11
25
  "test -f #{file}"
12
26
  end
@@ -6,7 +6,7 @@ module Serverspec
6
6
  # Linux kernel parameters
7
7
  %w( abi crypto debug dev fs kernel net sunrpc vm ).each do |param|
8
8
  if description_args.match(/^#{param}\./)
9
- ret = backend(Serverspec::Commands::Base).do_check("/sbin/sysctl -q -n #{description_args}")
9
+ ret = backend(Serverspec::Commands::Base).run_command("/sbin/sysctl -q -n #{description_args}")
10
10
  val = ret[:stdout].strip
11
11
  val = val.to_i if val.match(/^\d+$/)
12
12
  subject = Serverspec::Subject.new
@@ -1,3 +1,5 @@
1
+ require 'serverspec/matchers/be_mounted'
2
+ require 'serverspec/matchers/be_resolvable'
1
3
  require 'serverspec/matchers/be_enabled'
2
4
  require 'serverspec/matchers/be_file'
3
5
  require 'serverspec/matchers/be_directory'
@@ -0,0 +1,13 @@
1
+ RSpec::Matchers.define :be_mounted do
2
+ match do |path|
3
+ backend.check_mounted(example, path, @attr, @only_with)
4
+ end
5
+ chain :with do |attr|
6
+ @attr = attr
7
+ @only_with = false
8
+ end
9
+ chain :only_with do |attr|
10
+ @attr = attr
11
+ @only_with = true
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ RSpec::Matchers.define :be_resolvable do
2
+ match do |name|
3
+ backend.check_resolvable(example, name, @type)
4
+ end
5
+ chain :by do |type|
6
+ @type = type
7
+ end
8
+ end
@@ -5,7 +5,7 @@ RSpec::Matchers.define :contain do |pattern|
5
5
  else
6
6
  cmd = backend.commands.check_file_contain_within(file, pattern, @from, @to)
7
7
  end
8
- ret = backend.do_check(cmd)
8
+ ret = backend.run_command(cmd)
9
9
  ret[:exit_status] == 0
10
10
  end
11
11
  # for contain(pattern).from(/A/).to(/B/)
@@ -8,7 +8,7 @@ Use "return_stdout" matcher instead.
8
8
  ************************************
9
9
 
10
10
  EOF
11
- ret = backend.do_check(command)
11
+ ret = backend.run_command(command)
12
12
  ret[:stdout] =~ /#{expected}/
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  RSpec::Matchers.define :return_exit_status do |status|
2
2
  match do |command|
3
- ret = backend.do_check(command)
3
+ ret = backend.run_command(command)
4
4
  ret[:exit_status].to_i == status
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  RSpec::Matchers.define :return_stderr do |content|
2
2
  match do |command|
3
- ret = backend.do_check(command)
3
+ ret = backend.run_command(command)
4
4
  if content.instance_of?(Regexp)
5
5
  ret[:stderr] =~ content
6
6
  else
@@ -1,6 +1,6 @@
1
1
  RSpec::Matchers.define :return_stdout do |content|
2
2
  match do |command|
3
- ret = backend.do_check(command)
3
+ ret = backend.run_command(command)
4
4
  if content.instance_of?(Regexp)
5
5
  ret[:stdout] =~ content
6
6
  else
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.2.19"
2
+ VERSION = "0.2.20"
3
3
  end
@@ -10,6 +10,26 @@ describe 'check_file', :os => :debian do
10
10
  it { should eq 'test -f /etc/passwd' }
11
11
  end
12
12
 
13
+ describe 'check_mounted', :os => :debian do
14
+ subject { commands.check_mounted('/') }
15
+ it { should eq "mount | grep -w 'on /'" }
16
+ end
17
+
18
+ describe 'check_resolvable', :os => :debian do
19
+ context "resolve localhost by hosts" do
20
+ subject { commands.check_resolvable('localhost', 'hosts') }
21
+ it { should eq "grep -w localhost /etc/hosts" }
22
+ end
23
+ context "resolve localhost by dns" do
24
+ subject { commands.check_resolvable('localhost', 'dns') }
25
+ it { should eq "nslookup -timeout=1 localhost" }
26
+ end
27
+ context "resolve localhost with default settings" do
28
+ subject { commands.check_resolvable('localhost',nil) }
29
+ it { should eq 'getent hosts localhost' }
30
+ end
31
+ end
32
+
13
33
  describe 'check_directory', :os => :debian do
14
34
  subject { commands.check_directory('/var/log') }
15
35
  it { should eq 'test -d /var/log' }
@@ -7,6 +7,14 @@ describe 'Serverspec matchers of Debian family', :os => :debian do
7
7
  it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
8
8
  it_behaves_like 'support be_listening matcher', 22
9
9
  it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
10
+
11
+ it_behaves_like 'support be_mounted matcher', '/'
12
+ it_behaves_like 'support be_mounted.with matcher', '/'
13
+ it_behaves_like 'support be_mounted.only_with matcher', '/'
14
+
15
+ it_behaves_like 'support be_resolvable matcher', 'localhost'
16
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
17
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
10
18
  it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'See the sshd_config(5) manpage'
11
19
  it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
12
20
  it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
@@ -10,6 +10,26 @@ describe 'check_file', :os => :gentoo do
10
10
  it { should eq 'test -f /etc/passwd' }
11
11
  end
12
12
 
13
+ describe 'check_mounted', :os => :debian do
14
+ subject { commands.check_mounted('/') }
15
+ it { should eq "mount | grep -w 'on /'" }
16
+ end
17
+
18
+ describe 'check_resolvable', :os => :debian do
19
+ context "resolve localhost by hosts" do
20
+ subject { commands.check_resolvable('localhost', 'hosts') }
21
+ it { should eq "grep -w localhost /etc/hosts" }
22
+ end
23
+ context "resolve localhost by dns" do
24
+ subject { commands.check_resolvable('localhost', 'dns') }
25
+ it { should eq "nslookup -timeout=1 localhost" }
26
+ end
27
+ context "resolve localhost with default settings" do
28
+ subject { commands.check_resolvable('localhost',nil) }
29
+ it { should eq 'getent hosts localhost' }
30
+ end
31
+ end
32
+
13
33
  describe 'check_directory', :os => :gentoo do
14
34
  subject { commands.check_directory('/var/log') }
15
35
  it { should eq 'test -d /var/log' }
@@ -7,6 +7,14 @@ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
7
7
  it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
8
8
  it_behaves_like 'support be_listening matcher', 22
9
9
  it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
10
+
11
+ it_behaves_like 'support be_mounted matcher', '/'
12
+ it_behaves_like 'support be_mounted.with matcher', '/'
13
+ it_behaves_like 'support be_mounted.only_with matcher', '/'
14
+
15
+ it_behaves_like 'support be_resolvable matcher', 'localhost'
16
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
17
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
10
18
  it_behaves_like 'support be_directory matcher', '/etc/ssh'
11
19
  it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
12
20
  it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
@@ -10,6 +10,26 @@ describe 'check_file', :os => :redhat do
10
10
  it { should eq 'test -f /etc/passwd' }
11
11
  end
12
12
 
13
+ describe 'check_mounted', :os => :debian do
14
+ subject { commands.check_mounted('/') }
15
+ it { should eq "mount | grep -w 'on /'" }
16
+ end
17
+
18
+ describe 'check_resolvable', :os => :debian do
19
+ context "resolve localhost by hosts" do
20
+ subject { commands.check_resolvable('localhost', 'hosts') }
21
+ it { should eq "grep -w localhost /etc/hosts" }
22
+ end
23
+ context "resolve localhost by dns" do
24
+ subject { commands.check_resolvable('localhost', 'dns') }
25
+ it { should eq "nslookup -timeout=1 localhost" }
26
+ end
27
+ context "resolve localhost with default settings" do
28
+ subject { commands.check_resolvable('localhost',nil) }
29
+ it { should eq 'getent hosts localhost' }
30
+ end
31
+ end
32
+
13
33
  describe 'check_directory', :os => :redhat do
14
34
  subject { commands.check_directory('/var/log') }
15
35
  it { should eq 'test -d /var/log' }
@@ -8,6 +8,14 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
8
8
  it_behaves_like 'support be_running.under("not implemented") matcher', 'growthforecast'
9
9
  it_behaves_like 'support be_listening matcher', 22
10
10
  it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
11
+
12
+ it_behaves_like 'support be_mounted matcher', '/'
13
+ it_behaves_like 'support be_mounted.with matcher', '/'
14
+ it_behaves_like 'support be_mounted.only_with matcher', '/'
15
+
16
+ it_behaves_like 'support be_resolvable matcher', 'localhost'
17
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
18
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
11
19
  it_behaves_like 'support be_directory matcher', '/etc/ssh'
12
20
  it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
13
21
  it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
@@ -10,6 +10,26 @@ describe 'check_file', :os => :solaris do
10
10
  it { should eq 'test -f /etc/passwd' }
11
11
  end
12
12
 
13
+ describe 'check_mounted', :os => :debian do
14
+ subject { commands.check_mounted('/') }
15
+ it { should eq "mount | grep -w 'on /'" }
16
+ end
17
+
18
+ describe 'check_resolvable', :os => :debian do
19
+ context "resolve localhost by hosts" do
20
+ subject { commands.check_resolvable('localhost', 'hosts') }
21
+ it { should eq "grep -w localhost /etc/hosts" }
22
+ end
23
+ context "resolve localhost by dns" do
24
+ subject { commands.check_resolvable('localhost', 'dns') }
25
+ it { should eq "nslookup -timeout=1 localhost" }
26
+ end
27
+ context "resolve localhost with default settings" do
28
+ subject { commands.check_resolvable('localhost',nil) }
29
+ it { should eq 'getent hosts localhost' }
30
+ end
31
+ end
32
+
13
33
  describe 'check_directory', :os => :solaris do
14
34
  subject { commands.check_directory('/var/log') }
15
35
  it { should eq 'test -d /var/log' }
@@ -7,6 +7,14 @@ describe 'Serverspec matchers of Solaris family', :os => :solaris do
7
7
  it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
8
8
  it_behaves_like 'support be_listening matcher', 22
9
9
  it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
10
+
11
+ it_behaves_like 'support be_mounted matcher', '/'
12
+ it_behaves_like 'support be_mounted.with matcher', '/'
13
+ it_behaves_like 'support be_mounted.only_with matcher', '/'
14
+
15
+ it_behaves_like 'support be_resolvable matcher', 'localhost'
16
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
17
+ it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
10
18
  it_behaves_like 'support be_directory matcher', '/etc/ssh'
11
19
  it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'Configuration file for sshd(1m) (see also sshd_config(4))'
12
20
  it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ Dir[PROJECT_ROOT.join("spec/support/**/*.rb")].each { |file| require(file) }
10
10
  module Serverspec
11
11
  module Backend
12
12
  class Exec
13
- def do_check(cmd)
13
+ def run_command(cmd)
14
14
  if cmd =~ /invalid/
15
15
  {
16
16
  :stdout => ::RSpec.configuration.stdout,
@@ -94,6 +94,149 @@ shared_examples_for 'support be_listening matcher' do |valid_port|
94
94
  end
95
95
  end
96
96
 
97
+ shared_examples_for 'support be_mounted matcher' do |valid_mount|
98
+ describe 'be_mounted' do
99
+ describe valid_mount do
100
+ it { should be_mounted }
101
+ end
102
+
103
+ describe '/etc/thid_is_a_invalid_mount' do
104
+ it { should_not be_mounted }
105
+ end
106
+ end
107
+ end
108
+
109
+ shared_examples_for 'support be_mounted.with matcher' do |valid_mount|
110
+ describe 'be_mounted.with' do
111
+ before :all do
112
+ RSpec.configure do |c|
113
+ c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n"
114
+ end
115
+ end
116
+
117
+ describe valid_mount do
118
+ it { should be_mounted.with( :type => 'ext4' ) }
119
+ end
120
+
121
+ describe valid_mount do
122
+ it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
123
+ end
124
+
125
+ describe valid_mount do
126
+ it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
127
+ end
128
+
129
+ describe valid_mount do
130
+ it { should_not be_mounted.with( :type => 'xfs' ) }
131
+ end
132
+
133
+ describe valid_mount do
134
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
135
+ end
136
+
137
+ describe valid_mount do
138
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
139
+ end
140
+
141
+ describe '/etc/thid_is_a_invalid_mount' do
142
+ it { should_not be_mounted.with( :type => 'ext4' ) }
143
+ end
144
+ end
145
+ end
146
+
147
+
148
+ shared_examples_for 'support be_mounted.only_with matcher' do |valid_mount|
149
+ describe 'be_mounted.with' do
150
+ before :all do
151
+ RSpec.configure do |c|
152
+ c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n"
153
+ end
154
+ end
155
+
156
+ describe valid_mount do
157
+ it do
158
+ should be_mounted.only_with(
159
+ :device => '/dev/mapper/VolGroup-lv_root',
160
+ :type => 'ext4',
161
+ :options => {
162
+ :rw => true,
163
+ :mode => 620,
164
+ }
165
+ )
166
+ end
167
+ end
168
+
169
+ describe valid_mount do
170
+ it do
171
+ should_not be_mounted.only_with(
172
+ :device => '/dev/mapper/VolGroup-lv_root',
173
+ :type => 'ext4',
174
+ :options => {
175
+ :rw => true,
176
+ :mode => 620,
177
+ :bind => true,
178
+ }
179
+ )
180
+ end
181
+ end
182
+
183
+ describe valid_mount do
184
+ it do
185
+ should_not be_mounted.only_with(
186
+ :device => '/dev/mapper/VolGroup-lv_root',
187
+ :type => 'ext4',
188
+ :options => {
189
+ :rw => true,
190
+ }
191
+ )
192
+ end
193
+ end
194
+
195
+ describe valid_mount do
196
+ it do
197
+ should_not be_mounted.only_with(
198
+ :device => '/dev/mapper/VolGroup-lv_roooooooooot',
199
+ :type => 'ext4',
200
+ :options => {
201
+ :rw => true,
202
+ :mode => 620,
203
+ }
204
+ )
205
+ end
206
+ end
207
+
208
+ describe '/etc/thid_is_a_invalid_mount' do
209
+ it { should_not be_mounted.only_with( :type => 'ext4' ) }
210
+ end
211
+ end
212
+ end
213
+
214
+
215
+ shared_examples_for 'support be_resolvable matcher' do |valid_name|
216
+ describe 'be_resolvable' do
217
+ describe valid_name do
218
+ it { should be_resolvable }
219
+ end
220
+
221
+ describe 'invalid_name' do
222
+ it { should_not be_resolvable }
223
+ end
224
+ end
225
+ end
226
+
227
+
228
+ shared_examples_for 'support be_resolvable.by matcher' do |valid_name, type|
229
+ describe 'be_resolvable.by' do
230
+ describe valid_name do
231
+ it { should be_resolvable.by(type) }
232
+ end
233
+
234
+ describe 'invalid_name' do
235
+ it { should_not be_resolvable.by(type) }
236
+ end
237
+ end
238
+ end
239
+
97
240
  shared_examples_for 'support be_file matcher' do |valid_file|
98
241
  describe 'be_file' do
99
242
  describe valid_file do
@@ -907,4 +1050,4 @@ shared_examples_for 'support linux kernel parameter checking with regexp' do |pa
907
1050
  its(:value) { should_not match /invalid-string/ }
908
1051
  end
909
1052
  end
910
- end
1053
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 19
10
- version: 0.2.19
9
+ - 20
10
+ version: 0.2.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gosuke Miyashita
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-05-02 00:00:00 +09:00
18
+ date: 2013-05-04 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -141,9 +141,11 @@ files:
141
141
  - lib/serverspec/matchers/be_linked_to.rb
142
142
  - lib/serverspec/matchers/be_listening.rb
143
143
  - lib/serverspec/matchers/be_mode.rb
144
+ - lib/serverspec/matchers/be_mounted.rb
144
145
  - lib/serverspec/matchers/be_owned_by.rb
145
146
  - lib/serverspec/matchers/be_permissive.rb
146
147
  - lib/serverspec/matchers/be_readable.rb
148
+ - lib/serverspec/matchers/be_resolvable.rb
147
149
  - lib/serverspec/matchers/be_running.rb
148
150
  - lib/serverspec/matchers/be_user.rb
149
151
  - lib/serverspec/matchers/be_writable.rb