serverspec 2.0.0.beta6 → 2.0.0.beta7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa3da35f1496825983cc458a77052918cd8ed9fa
4
- data.tar.gz: 63b88a49efb03e61d44c82b1908e9ad7c450b72e
3
+ metadata.gz: 86276d22b163697d65c60b346e9b6e6b0ff9e5cb
4
+ data.tar.gz: 58808a070ee544fe9a86a7a3f50c52a35149ebcc
5
5
  SHA512:
6
- metadata.gz: c8fc95f52f7e6f6e6571dbdca21935ca64345ac7bf1ccc6bc2971ea4fe4cdd56071b70457ca0f4918cc774737e8093ef0608a658b8caf7c4fd2a9980f43555ab
7
- data.tar.gz: 5d96c7c90724bfcc0ce4a96c7960dde0a9998595f80670ccfb9f029fe63925d0569dbc460b20223e481506ff50a32b17f920defc7148fcff70e819cb9ea66e51
6
+ metadata.gz: cf3996aefa9f11b279130f27ea47b27673d47e0ae25d9929b9e3103294c59c645a91911d1e3e099250db39925c39402109cb39ca5fb9593a623acd97e556a8a1
7
+ data.tar.gz: 1f91b85d4ea7f6bc52d54afbc13244b689bb97ac93d7ada9544b980181b64bacb0cabfa2879e8773c0f2b1cd216dffbd5cbc8ad89b8c972c7ceae40363697f67
@@ -1,5 +1,3 @@
1
- require 'serverspec/helper/os'
2
-
3
1
  # Subject type helper
4
2
  require 'serverspec/helper/type'
5
3
  extend Serverspec::Helper::Type
@@ -103,13 +103,18 @@ describe package('apache2'), :if => os[:family] == 'Ubuntu' do
103
103
  end
104
104
 
105
105
  describe service('httpd'), :if => os[:family] == 'RedHat' do
106
- it { should be_enabled }
107
- it { should be_running }
106
+ it { should be_enabled }
107
+ it { should be_running }
108
108
  end
109
109
 
110
110
  describe service('apache2'), :if => os[:family] == 'Ubuntu' do
111
- it { should be_enabled }
112
- it { should be_running }
111
+ it { should be_enabled }
112
+ it { should be_running }
113
+ end
114
+
115
+ describe service('org.apache.httpd'), :if => os[:family] == 'Darwin' do
116
+ it { should be_enabled }
117
+ it { should be_running }
113
118
  end
114
119
 
115
120
  describe port(80) do
@@ -117,16 +122,16 @@ describe port(80) do
117
122
  end
118
123
  EOF
119
124
 
120
- if File.exists? "spec/#{@hostname}/httpd_spec.rb"
121
- old_content = File.read("spec/#{@hostname}/httpd_spec.rb")
125
+ if File.exists? "spec/#{@hostname}/sample_spec.rb"
126
+ old_content = File.read("spec/#{@hostname}/sample_spec.rb")
122
127
  if old_content != content
123
- $stderr.puts "!! spec/#{@hostname}/httpd_spec.rb already exists and differs from template"
128
+ $stderr.puts "!! spec/#{@hostname}/sample_spec.rb already exists and differs from template"
124
129
  end
125
130
  else
126
- File.open("spec/#{@hostname}/httpd_spec.rb", 'w') do |f|
131
+ File.open("spec/#{@hostname}/sample_spec.rb", 'w') do |f|
127
132
  f.puts content
128
133
  end
129
- puts " + spec/#{@hostname}/httpd_spec.rb"
134
+ puts " + spec/#{@hostname}/sample_spec.rb"
130
135
  end
131
136
  end
132
137
 
@@ -233,11 +238,14 @@ end
233
238
  end
234
239
 
235
240
  def self.spec_helper_template
236
- template = <<-EOF
241
+ template = <<-'EOF'
237
242
  require 'serverspec'
238
243
  <% if @backend_type == 'Ssh' -%>
239
244
  require 'net/ssh'
240
245
  <% end -%>
246
+ <%- if @vagrant -%>
247
+ require 'tempfile'
248
+ <% end -%>
241
249
  <% if @backend_type == 'WinRM' -%>
242
250
  require 'winrm'
243
251
  <% end -%>
@@ -262,31 +270,22 @@ else
262
270
  end
263
271
 
264
272
  <%- if @backend_type == 'Ssh' -%>
265
- host = ENV['TARGET_HOST']
266
- options = Net::SSH::Config.for(host)
273
+ host = ENV['TARGET_HOST']
267
274
 
268
275
  <%- 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]
282
- end
283
- end
284
- end
276
+ `vagrant up #{host}`
277
+
278
+ config = Tempfile.new('', Dir.tmpdir)
279
+ `vagrant ssh-config #{host} > #{config.path}`
285
280
 
281
+ options = Net::SSH::Config.for(host, [config.path])
282
+ <%- else -%>
283
+ options = Net::SSH::Config.for(host)
286
284
  <%- end -%>
285
+
287
286
  options[:user] ||= Etc.getlogin
288
287
 
289
- set :host, host
288
+ set :host, options[:host_name] || host
290
289
  set :ssh_options, options
291
290
  <%- end -%>
292
291
  <%- end -%>
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module Serverspec
2
4
  module Type
3
5
  class File < Base
@@ -93,6 +95,15 @@ module Serverspec
93
95
  def version?(version)
94
96
  @runner.check_file_version(@name, version)
95
97
  end
98
+
99
+ def mtime
100
+ d = backend.get_file_mtime(@name).stdout.strip
101
+ DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
102
+ end
103
+
104
+ def size
105
+ backend.get_file_size(@name).stdout.strip.to_i
106
+ end
96
107
  end
97
108
  end
98
109
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "2.0.0.beta6"
2
+ VERSION = "2.0.0.beta7"
3
3
  end
data/serverspec.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency "rspec", "~> 3.0.0"
22
22
  spec.add_runtime_dependency "rspec-its"
23
- spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta4"
23
+ spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta6"
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake", "~> 10.1.1"
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta6
4
+ version: 2.0.0.beta7
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-07 00:00:00.000000000 Z
11
+ date: 2014-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0.beta4
47
+ version: 2.0.0.beta6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0.beta4
54
+ version: 2.0.0.beta6
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +101,6 @@ files:
101
101
  - lib/serverspec.rb
102
102
  - lib/serverspec/commands/base.rb
103
103
  - lib/serverspec/helper.rb
104
- - lib/serverspec/helper/os.rb
105
104
  - lib/serverspec/helper/properties.rb
106
105
  - lib/serverspec/helper/type.rb
107
106
  - lib/serverspec/matchers.rb
@@ -1,29 +0,0 @@
1
- module Serverspec
2
- module Helper
3
- [
4
- 'DetectOS',
5
- 'AIX',
6
- 'Arch',
7
- 'Darwin',
8
- 'Debian',
9
- 'Fedora',
10
- 'FreeBSD',
11
- 'FreeBSD10',
12
- 'Gentoo',
13
- 'Plamo',
14
- 'RedHat',
15
- 'RedHat7',
16
- 'SmartOS',
17
- 'Solaris',
18
- 'Solaris10',
19
- 'Solaris11',
20
- 'Windows',
21
- ].each do |os|
22
- eval <<-EOF
23
- module #{os}
24
- include self.class.const_get('Specinfra').const_get('Helper').const_get('#{os}')
25
- end
26
- EOF
27
- end
28
- end
29
- end