serverspec 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/serverspec/helper.rb +5 -11
- data/lib/serverspec/matchers/be_directory.rb +1 -1
- data/lib/serverspec/matchers/be_enabled.rb +1 -1
- data/lib/serverspec/matchers/be_file.rb +1 -1
- data/lib/serverspec/matchers/be_group.rb +1 -1
- data/lib/serverspec/matchers/be_grouped_into.rb +1 -1
- data/lib/serverspec/matchers/be_installed.rb +1 -1
- data/lib/serverspec/matchers/be_listening.rb +1 -1
- data/lib/serverspec/matchers/be_mode.rb +1 -1
- data/lib/serverspec/matchers/be_owned_by.rb +1 -1
- data/lib/serverspec/matchers/be_running.rb +2 -2
- data/lib/serverspec/matchers/be_user.rb +1 -1
- data/lib/serverspec/matchers/contain.rb +1 -1
- data/lib/serverspec/setup.rb +9 -1
- data/lib/serverspec/version.rb +1 -1
- data/lib/serverspec.rb +1 -0
- metadata +75 -86
data/lib/serverspec/helper.rb
CHANGED
@@ -1,25 +1,19 @@
|
|
1
|
-
require 'net/ssh'
|
2
1
|
require 'etc'
|
3
2
|
|
4
3
|
module Serverspec
|
5
4
|
module Helper
|
6
|
-
def ssh_exec(
|
7
|
-
|
8
|
-
user = options[:user] || Etc.getlogin
|
9
|
-
|
10
|
-
ret = nil
|
11
|
-
Net::SSH.start(host, user, options) do |ssh|
|
12
|
-
ret = ssh_exec!(ssh, "sudo #{cmd}")
|
13
|
-
end
|
14
|
-
ret
|
5
|
+
def ssh_exec(cmd, opt={})
|
6
|
+
ssh_exec!("sudo #{cmd}")
|
15
7
|
end
|
16
8
|
|
17
9
|
private
|
18
|
-
def ssh_exec!(
|
10
|
+
def ssh_exec!(command)
|
19
11
|
stdout_data = ''
|
20
12
|
stderr_data = ''
|
21
13
|
exit_code = nil
|
22
14
|
exit_signal = nil
|
15
|
+
|
16
|
+
ssh = RSpec.configuration.ssh
|
23
17
|
ssh.open_channel do |channel|
|
24
18
|
channel.request_pty do |ch, success|
|
25
19
|
abort "Could not obtain pty " if !success
|
@@ -1,8 +1,8 @@
|
|
1
1
|
RSpec::Matchers.define :be_running do
|
2
2
|
match do |actual|
|
3
|
-
ret = ssh_exec(
|
3
|
+
ret = ssh_exec(commands.check_running(actual))
|
4
4
|
if ret[:exit_code] == 1
|
5
|
-
ret = ssh_exec(
|
5
|
+
ret = ssh_exec(commands.check_process(actual))
|
6
6
|
end
|
7
7
|
ret[:exit_code] == 0
|
8
8
|
end
|
data/lib/serverspec/setup.rb
CHANGED
@@ -57,10 +57,18 @@ EOF
|
|
57
57
|
content = <<-EOF
|
58
58
|
require 'serverspec'
|
59
59
|
require 'pathname'
|
60
|
+
require 'net/ssh'
|
60
61
|
|
61
62
|
RSpec.configure do |c|
|
62
63
|
c.before do
|
63
|
-
|
64
|
+
host = File.basename(Pathname.new(example.metadata[:location]).dirname)
|
65
|
+
if c.host != host
|
66
|
+
c.ssh.close if c.ssh
|
67
|
+
c.host = host
|
68
|
+
options = Net::SSH::Config.for(c.host)
|
69
|
+
user = options[:user] || Etc.getlogin
|
70
|
+
c.ssh = Net::SSH.start(c.host, user, options)
|
71
|
+
end
|
64
72
|
end
|
65
73
|
end
|
66
74
|
EOF
|
data/lib/serverspec/version.rb
CHANGED
data/lib/serverspec.rb
CHANGED
metadata
CHANGED
@@ -1,90 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 12
|
10
|
-
version: 0.0.12
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.13
|
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
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: net-ssh
|
23
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
57
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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
78
|
description: RSpec tests for your provisioned servers
|
79
|
-
email:
|
79
|
+
email:
|
80
80
|
- gosukenator@gmail.com
|
81
|
-
executables:
|
81
|
+
executables:
|
82
82
|
- serverspec-init
|
83
83
|
extensions: []
|
84
|
-
|
85
84
|
extra_rdoc_files: []
|
86
|
-
|
87
|
-
files:
|
85
|
+
files:
|
88
86
|
- .gitignore
|
89
87
|
- Gemfile
|
90
88
|
- LICENSE.txt
|
@@ -122,41 +120,32 @@ files:
|
|
122
120
|
- spec/solaris/matchers_spec.rb
|
123
121
|
- spec/spec_helper.rb
|
124
122
|
- spec/support/shared_matcher_examples.rb
|
125
|
-
has_rdoc: true
|
126
123
|
homepage: https://github.com/mizzy/serverspec
|
127
|
-
licenses:
|
124
|
+
licenses:
|
128
125
|
- MIT
|
129
126
|
post_install_message:
|
130
127
|
rdoc_options: []
|
131
|
-
|
132
|
-
require_paths:
|
128
|
+
require_paths:
|
133
129
|
- lib
|
134
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
131
|
none: false
|
136
|
-
requirements:
|
137
|
-
- -
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
|
140
|
-
|
141
|
-
- 0
|
142
|
-
version: "0"
|
143
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
137
|
none: false
|
145
|
-
requirements:
|
146
|
-
- -
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
version: "0"
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
152
142
|
requirements: []
|
153
|
-
|
154
143
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
144
|
+
rubygems_version: 1.8.25
|
156
145
|
signing_key:
|
157
146
|
specification_version: 3
|
158
147
|
summary: RSpec tests for your provisioned servers
|
159
|
-
test_files:
|
148
|
+
test_files:
|
160
149
|
- spec/debian/matchers_spec.rb
|
161
150
|
- spec/gentoo/matchers_spec.rb
|
162
151
|
- spec/redhat/matchers_spec.rb
|