rspec-system-puppet 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -228,4 +228,38 @@ host { 'puppet':
228
228
  result
229
229
  end
230
230
  end
231
+
232
+ # Run facter on a remote machine
233
+ #
234
+ # @param opts [Hash] a hash of opts
235
+ # @option opts [RSpecSystem::Node] :node node to execute DSL on
236
+ # @return [Hash] a hash of results
237
+ # @yield [result] yields result when called as a block
238
+ # @yieldparam result [Hash] a hash containing :facts, :exit_code, :stdout and
239
+ # :stderr
240
+ def facter(opts = {})
241
+ # Defaults
242
+ opts = {
243
+ :node => rspec_system_node_set.default_node,
244
+ }.merge(opts)
245
+
246
+ node = opts[:node]
247
+
248
+ raise "Must specify a node" unless node
249
+
250
+ cmd = "facter -y"
251
+ result = system_run(:n => node, :c => cmd)
252
+
253
+ begin
254
+ facts = YAML::load(result[:stdout])
255
+ result[:facts] = facts
256
+ rescue
257
+ end
258
+
259
+ if block_given?
260
+ yield(result)
261
+ else
262
+ result
263
+ end
264
+ end
231
265
  end
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # Metadata
4
4
  s.name = "rspec-system-puppet"
5
- s.version = "0.3.3"
5
+ s.version = "0.3.4"
6
6
  s.authors = ["Ken Barber"]
7
7
  s.email = ["ken@bob.sh"]
8
8
  s.homepage = "https://github.com/kbarber/rspec-system-puppet"
@@ -23,17 +23,16 @@ describe "basic tests:" do
23
23
  end
24
24
 
25
25
  it 'facter domain should return something valid' do
26
- system_run("facter domain") do |r|
27
- r[:stdout].should =~ /[a-z]+/
28
- r[:stderr].should == ''
26
+ facter do |r|
27
+ r[:facts]['domain'].should =~ /[a-z]+/
29
28
  r[:exit_code].should == 0
30
29
  end
31
30
  end
32
31
 
33
32
  it 'facter fqdn should return something valid' do
34
- system_run("facter fqdn") do |r|
35
- r[:stdout].should =~ /vm/
33
+ facter do |r|
36
34
  r[:stderr].should == ''
35
+ r[:facts]['fqdn'] =~ /vm/
37
36
  r[:exit_code].should == 0
38
37
  end
39
38
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-system-puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 3
10
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Barber
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-19 00:00:00 Z
18
+ date: 2013-04-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec-system