serverspec 2.0.0.beta5 → 2.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b36a55510e28dba398ec529d17c58bd6d5d209
4
- data.tar.gz: cc5a71e21b65c51ad8b09dd15b80727c02d4d149
3
+ metadata.gz: fa3da35f1496825983cc458a77052918cd8ed9fa
4
+ data.tar.gz: 63b88a49efb03e61d44c82b1908e9ad7c450b72e
5
5
  SHA512:
6
- metadata.gz: 087b2a6bfc2d5f6f6df8fb81302ad0dbf9ae4d7dcf13619cfffda53106beeb36859caae13d1ee60f36d8c65118941d47c13e218f16f5fc56257885e965eed091
7
- data.tar.gz: f167bc461d6fb27e4404f0015cdc7b38182e9710c120fd904c4e011520244af2487641671897b448093748f9802567380943f480094788f04f2e1208d3ec5feb
6
+ metadata.gz: c8fc95f52f7e6f6e6571dbdca21935ca64345ac7bf1ccc6bc2971ea4fe4cdd56071b70457ca0f4918cc774737e8093ef0608a658b8caf7c4fd2a9980f43555ab
7
+ data.tar.gz: 5d96c7c90724bfcc0ce4a96c7960dde0a9998595f80670ccfb9f029fe63925d0569dbc460b20223e481506ff50a32b17f920defc7148fcff70e819cb9ea66e51
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "octorelease"
2
+ begin
3
+ require "rspec/core/rake_task"
4
+ require "octorelease"
5
+ rescue LoadError
6
+ end
4
7
 
5
- RSpec::Core::RakeTask.new('spec') do |t|
6
- t.pattern = 'spec/*/*_spec.rb'
8
+ if defined?(RSpec)
9
+ RSpec::Core::RakeTask.new('spec') do |t|
10
+ t.pattern = 'spec/*/*_spec.rb'
11
+ end
7
12
  end
@@ -94,22 +94,26 @@ EOF
94
94
  content = <<-EOF
95
95
  require 'spec_helper'
96
96
 
97
- describe package('httpd') do
97
+ describe package('httpd'), :if => os[:family] == 'RedHat' do
98
98
  it { should be_installed }
99
99
  end
100
100
 
101
- describe service('httpd') do
101
+ describe package('apache2'), :if => os[:family] == 'Ubuntu' do
102
+ it { should be_installed }
103
+ end
104
+
105
+ describe service('httpd'), :if => os[:family] == 'RedHat' do
102
106
  it { should be_enabled }
103
107
  it { should be_running }
104
108
  end
105
109
 
106
- describe port(80) do
107
- it { should be_listening }
110
+ describe service('apache2'), :if => os[:family] == 'Ubuntu' do
111
+ it { should be_enabled }
112
+ it { should be_running }
108
113
  end
109
114
 
110
- describe file('/etc/httpd/conf/httpd.conf') do
111
- it { should be_file }
112
- its(:content) { should match /ServerName #{@hostname}/ }
115
+ describe port(80) do
116
+ it { should be_listening }
113
117
  end
114
118
  EOF
115
119
 
@@ -157,11 +161,27 @@ EOF
157
161
  require 'rake'
158
162
  require 'rspec/core/rake_task'
159
163
 
160
- RSpec::Core::RakeTask.new(:spec) do |t|
161
- t.pattern = 'spec/*/*_spec.rb'
162
- end
163
-
164
+ task :spec => 'spec:all'
164
165
  task :default => :spec
166
+
167
+ namespace :spec do
168
+ targets = []
169
+ Dir.glob('./spec/*').each do |dir|
170
+ next unless File.directory?(dir)
171
+ targets << File.basename(dir)
172
+ end
173
+
174
+ task :all => targets
175
+ task :default => :all
176
+
177
+ targets.each do |target|
178
+ desc "Run serverspec tests to #{target}"
179
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
180
+ ENV['TARGET_HOST'] = target
181
+ t.pattern = "spec/#{target}/*_spec.rb"
182
+ end
183
+ end
184
+ end
165
185
  EOF
166
186
  if File.exists? 'Rakefile'
167
187
  old_content = File.read('Rakefile')
@@ -190,7 +210,7 @@ task :default => :spec
190
210
  list_of_vms = []
191
211
  if vagrant_list != ''
192
212
  vagrant_list.each_line do |line|
193
- if match = /([\w-]+[\s]+)(created|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\))/.match(line)
213
+ if match = /([\w-]+[\s]+)(created|aborted|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\))/.match(line)
194
214
  list_of_vms << match[1].strip!
195
215
  end
196
216
  end
@@ -215,9 +235,6 @@ task :default => :spec
215
235
  def self.spec_helper_template
216
236
  template = <<-EOF
217
237
  require 'serverspec'
218
- <% if @os_type == 'UN*X' && @backend_type == 'Ssh' -%>
219
- require 'pathname'
220
- <% end -%>
221
238
  <% if @backend_type == 'Ssh' -%>
222
239
  require 'net/ssh'
223
240
  <% end -%>
@@ -228,64 +245,59 @@ require 'winrm'
228
245
  include Specinfra::Helper::<%= @backend_type %>
229
246
  <% if @os_type == 'UN*X' -%>
230
247
  include Specinfra::Helper::DetectOS
231
- <% else -%>
248
+ <% else -%>
232
249
  include Specinfra::Helper::Windows
233
250
  <% end -%>
234
251
 
235
- <% if @os_type == 'UN*X' -%>
236
- RSpec.configure do |c|
237
- if ENV['ASK_SUDO_PASSWORD']
252
+ <% if @os_type == 'UN*X' && @backend_type == 'Ssh' -%>
253
+ if ENV['ASK_SUDO_PASSWORD']
254
+ begin
238
255
  require 'highline/import'
239
- c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
240
- else
241
- c.sudo_password = ENV['SUDO_PASSWORD']
256
+ rescue LoadError
257
+ fail "highline is not available. Try installing it."
242
258
  end
243
- <%- if @backend_type == 'Ssh' -%>
244
- c.before :all do
245
- block = self.class.metadata[:example_group_block]
246
- if RUBY_VERSION.start_with?('1.8')
247
- file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
248
- else
249
- file = block.source_location.first
250
- end
251
- host = File.basename(Pathname.new(file).dirname)
252
- if c.host != host
253
- c.ssh.close if c.ssh
254
- c.host = host
255
- options = Net::SSH::Config.for(c.host)
256
- user = options[:user] || Etc.getlogin
257
- <%- if @vagrant -%>
258
- vagrant_up = `vagrant up #{@hostname}`
259
- config = `vagrant ssh-config #{@hostname}`
260
- if config != ''
261
- config.each_line do |line|
262
- if match = /HostName (.*)/.match(line)
263
- host = match[1]
264
- elsif match = /User (.*)/.match(line)
265
- user = match[1]
266
- elsif match = /IdentityFile (.*)/.match(line)
267
- options[:keys] = [match[1].gsub(/\"/,'')]
268
- elsif match = /Port (.*)/.match(line)
269
- options[:port] = match[1]
270
- end
271
- end
272
- end
273
- <%- end -%>
274
- c.ssh = Net::SSH.start(host, user, options)
259
+ set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
260
+ else
261
+ set :sudo_password, ENV['SUDO_PASSWORD']
262
+ end
263
+
264
+ <%- if @backend_type == 'Ssh' -%>
265
+ host = ENV['TARGET_HOST']
266
+ options = Net::SSH::Config.for(host)
267
+
268
+ <%- if @vagrant -%>
269
+ `vagrant up \#{ENV['TARGET_HOST']}`
270
+
271
+ config = `vagrant ssh-config \#{ENV['TARGET_HOST']}`
272
+ if config != ''
273
+ config.each_line do |line|
274
+ if match = /HostName (.*)/.match(line)
275
+ host = match[1]
276
+ elsif match = /User (.*)/.match(line)
277
+ options[:user] = match[1]
278
+ elsif match = /IdentityFile (.*)/.match(line)
279
+ options[:keys] = [match[1].gsub(/\"/,'')]
280
+ elsif match = /Port (.*)/.match(line)
281
+ options[:port] = match[1]
275
282
  end
276
283
  end
277
- <%- end -%>
278
284
  end
279
- <% end -%>
285
+
286
+ <%- end -%>
287
+ options[:user] ||= Etc.getlogin
288
+
289
+ set :host, host
290
+ set :ssh_options, options
291
+ <%- end -%>
292
+ <%- end -%>
293
+
280
294
  <% if @backend_type == 'WinRM'-%>
281
- RSpec.configure do |c|
282
- user = <username>
283
- pass = <password>
284
- endpoint = "http://<hostname>:5985/wsman"
295
+ user = <username>
296
+ pass = <password>
297
+ endpoint = "http://<hostname>:5985/wsman"
285
298
 
286
- c.winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
287
- c.winrm.set_timeout 300 # 5 minutes max timeout for any operation
288
- end
299
+ c.winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
300
+ c.winrm.set_timeout 300 # 5 minutes max timeout for any operation
289
301
  <% end -%>
290
302
  EOF
291
303
  template
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "2.0.0.beta5"
2
+ VERSION = "2.0.0.beta6"
3
3
  end
data/serverspec.gemspec CHANGED
@@ -18,13 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "net-ssh"
22
21
  spec.add_runtime_dependency "rspec", "~> 3.0.0"
23
22
  spec.add_runtime_dependency "rspec-its"
24
- spec.add_runtime_dependency "highline"
25
- spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta2"
23
+ spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta4"
26
24
  spec.add_development_dependency "bundler", "~> 1.3"
27
25
  spec.add_development_dependency "rake", "~> 10.1.1"
28
- spec.add_development_dependency "octokit", "~> 2.7.2"
29
- spec.add_development_dependency "octorelease"
30
26
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta5
4
+ version: 2.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-05 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: net-ssh
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rspec
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -52,34 +38,20 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: highline
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: specinfra
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: 2.0.0.beta2
47
+ version: 2.0.0.beta4
76
48
  type: :runtime
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: 2.0.0.beta2
54
+ version: 2.0.0.beta4
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: bundler
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -108,34 +80,6 @@ dependencies:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
82
  version: 10.1.1
111
- - !ruby/object:Gem::Dependency
112
- name: octokit
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 2.7.2
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 2.7.2
125
- - !ruby/object:Gem::Dependency
126
- name: octorelease
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
83
  description: RSpec tests for your servers configured by Puppet, Chef or anything else
140
84
  email:
141
85
  - gosukenator@gmail.com