serverspec 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/serverspec.rb CHANGED
@@ -7,12 +7,14 @@ require 'serverspec/setup'
7
7
  require 'serverspec/commands/base'
8
8
  require 'serverspec/commands/redhat'
9
9
  require 'serverspec/commands/debian'
10
+ require 'serverspec/commands/gentoo'
10
11
  require 'serverspec/commands/solaris'
11
12
 
12
13
  RSpec.configure do |c|
13
14
  c.include(Serverspec::Helper)
14
15
  c.include(Serverspec::RedHatHelper, :os => :redhat)
15
16
  c.include(Serverspec::DebianHelper, :os => :debian)
17
+ c.include(Serverspec::GentooHelper, :os => :gentoo)
16
18
  c.include(Serverspec::SolarisHelper, :os => :solaris)
17
19
  c.add_setting :host, :default => nil
18
20
  end
@@ -35,6 +35,10 @@ module Serverspec
35
35
  "service #{service} status"
36
36
  end
37
37
 
38
+ def check_process process
39
+ "ps -e | grep -qw #{process}"
40
+ end
41
+
38
42
  def check_file_contain file, expected_pattern
39
43
  "grep -q '#{expected_pattern}' #{file} "
40
44
  end
@@ -0,0 +1,13 @@
1
+ module Serverspec
2
+ module Commands
3
+ class Gentoo < Base
4
+ def check_enabled service
5
+ "/sbin/rc-update show | grep '^\\s*#{service}\\s*|\\s*\\(boot\\|default\\)'"
6
+ end
7
+
8
+ def check_installed package
9
+ "/usr/bin/eix #{package} --installed"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -61,6 +61,12 @@ module Serverspec
61
61
  end
62
62
  end
63
63
 
64
+ module GentooHelper
65
+ def commands
66
+ Serverspec::Commands::Gentoo.new
67
+ end
68
+ end
69
+
64
70
  module SolarisHelper
65
71
  def commands
66
72
  Serverspec::Commands::Solaris.new
@@ -1,6 +1,9 @@
1
1
  RSpec::Matchers.define :be_running do
2
2
  match do |actual|
3
3
  ret = ssh_exec(RSpec.configuration.host, commands.check_running(actual))
4
+ if ret[:exit_code] == 1
5
+ ret = ssh_exec(RSpec.configuration.host, commands.check_process(actual))
6
+ end
4
7
  ret[:exit_code] == 0
5
8
  end
6
9
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
4
+ let(:test_server_host) { 'serverspec-gentoo-host' }
5
+
6
+ it_behaves_like 'support be_enabled matcher', 'sshd'
7
+ it_behaves_like 'support be_installed matcher', 'openssh'
8
+ it_behaves_like 'support be_running matcher', 'sshd'
9
+ it_behaves_like 'support be_listening matcher', 22
10
+ it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
11
+ it_behaves_like 'support be_directory matcher', '/etc/ssh'
12
+ it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
13
+ it_behaves_like 'support be_user matcher', 'root'
14
+ it_behaves_like 'support be_group matcher', 'wheel'
15
+ end
@@ -12,4 +12,7 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
12
12
  it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
13
13
  it_behaves_like 'support be_user matcher', 'root'
14
14
  it_behaves_like 'support be_group matcher', 'wheel'
15
+
16
+ # Test for case of not registered in the service, but running as process.
17
+ it_behaves_like 'support be_running matcher', 'udevd'
15
18
  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.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -92,6 +92,7 @@ files:
92
92
  - lib/serverspec.rb
93
93
  - lib/serverspec/commands/base.rb
94
94
  - lib/serverspec/commands/debian.rb
95
+ - lib/serverspec/commands/gentoo.rb
95
96
  - lib/serverspec/commands/redhat.rb
96
97
  - lib/serverspec/commands/solaris.rb
97
98
  - lib/serverspec/helper.rb
@@ -109,6 +110,7 @@ files:
109
110
  - lib/serverspec/version.rb
110
111
  - serverspec.gemspec
111
112
  - spec/debian/matchers_spec.rb
113
+ - spec/gentoo/matchers_spec.rb
112
114
  - spec/redhat/matchers_spec.rb
113
115
  - spec/solaris/matchers_spec.rb
114
116
  - spec/spec_helper.rb
@@ -134,12 +136,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
136
  version: '0'
135
137
  requirements: []
136
138
  rubyforge_project:
137
- rubygems_version: 1.8.23
139
+ rubygems_version: 1.8.25
138
140
  signing_key:
139
141
  specification_version: 3
140
142
  summary: RSpec tests for your provisioned servers
141
143
  test_files:
142
144
  - spec/debian/matchers_spec.rb
145
+ - spec/gentoo/matchers_spec.rb
143
146
  - spec/redhat/matchers_spec.rb
144
147
  - spec/solaris/matchers_spec.rb
145
148
  - spec/spec_helper.rb