serverspec 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,6 +67,10 @@ module Serverspec
67
67
  def check_installed_by_gem name
68
68
  "gem list --local | grep #{name}"
69
69
  end
70
+
71
+ def check_belonging_group user, group
72
+ "id #{user} | awk '{print $2}' | grep #{group}"
73
+ end
70
74
  end
71
75
  end
72
76
  end
@@ -13,4 +13,4 @@ require 'serverspec/matchers/be_grouped_into'
13
13
  require 'serverspec/matchers/have_cron_entry'
14
14
  require 'serverspec/matchers/be_linked_to'
15
15
  require 'serverspec/matchers/be_installed_by_gem'
16
-
16
+ require 'serverspec/matchers/belong_to_group'
@@ -0,0 +1,6 @@
1
+ RSpec::Matchers.define :belong_to_group do |group|
2
+ match do |user|
3
+ ret = ssh_exec(commands.check_belonging_group(user, group))
4
+ ret[:exit_code] == 0
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -25,4 +25,7 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
25
25
  it_behaves_like 'support have_cron_entry.with_user matcher', 'cron', '* * * * * /usr/bin/foo', 'root'
26
26
 
27
27
  it behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
28
+
29
+ it behaves_like 'support belong_to_group matcher', 'root', 'root'
30
+
28
31
  end
@@ -202,3 +202,15 @@ shared_examples_for 'support be_installed_by_gem.with_version matcher' do |name,
202
202
  end
203
203
  end
204
204
  end
205
+
206
+ shared_examples_for 'support belong_to_group matcher' do |name, group|
207
+ describe 'belong_to_group' do
208
+ describe user do
209
+ it { should belong_to_group group }
210
+ end
211
+
212
+ describe 'dummyuser' do
213
+ it { should_not belong_to_group 'dummygroup' }
214
+ end
215
+ end
216
+ 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: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 16
10
- version: 0.0.16
9
+ - 17
10
+ version: 0.0.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gosuke Miyashita
@@ -112,6 +112,7 @@ files:
112
112
  - lib/serverspec/matchers/be_owned_by.rb
113
113
  - lib/serverspec/matchers/be_running.rb
114
114
  - lib/serverspec/matchers/be_user.rb
115
+ - lib/serverspec/matchers/belong_to_group.rb
115
116
  - lib/serverspec/matchers/contain.rb
116
117
  - lib/serverspec/matchers/have_cron_entry.rb
117
118
  - lib/serverspec/setup.rb