Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed spec for system_profiler

  • Loading branch information...
commit fb1c5ab1368b88be6db2ab50afea2339599c0851 1 parent 5da36d2
authored December 06, 2012 btm committed December 06, 2012
6  Gemfile
@@ -2,5 +2,9 @@ source :rubygems
2 2
 
3 3
 gemspec
4 4
 
5  
-gem "sigar", :group => :development, :platform => "ruby"
  5
+group :development do
  6
+  gem "sigar", :platform => "ruby"
  7
+  gem 'plist'
  8
+end
  9
+
6 10
 
5  lib/ohai/plugins/darwin/system_profiler.rb
@@ -15,14 +15,12 @@
15 15
 # See the License for the specific language governing permissions and
16 16
 # limitations under the License.
17 17
 #
18  
-
19 18
 provides "system_profile"
20 19
 
21  
-begin  
  20
+begin
22 21
   require 'plist'
23 22
 
24 23
   system_profile Array.new
25  
-
26 24
   detail_level = {
27 25
     'mini' => [
28 26
       "SPParallelATAData",
@@ -66,7 +64,6 @@
66 64
   end
67 65
 
68 66
   system_profile.sort_by! { |h| h['_dataType'] }
69  
-
70 67
 rescue LoadError => e
71 68
   Ohai::Log.debug("Can't load gem: #{e})")
72 69
 end
18  spec/ohai/plugins/darwin/system_profiler_spec.rb
... ...
@@ -1,6 +1,6 @@
1 1
 #
2  
-# Author:: Adam Jacob (<adam@opscode.com>)
3  
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
  2
+# Author:: Paul Mooring (<paul@opscode.com>)
  3
+# Copyright:: Copyright (c) 2012 Opscode, Inc.
4 4
 # License:: Apache License, Version 2.0
5 5
 #
6 6
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,11 +28,15 @@
28 28
   end
29 29
   
30 30
   it "should return the right serial number" do
31  
-    @ohai.stub!(:popen4).with("system_profiler -xml -detailLevel full SPHardwareDataType").and_yield(nil, nil, SystemProfilerOutput::Full, nil)
32  
-    @ohai.stub!(:popen4).with("system_profiler -xml -detailLevel mini").and_yield(nil, nil, SystemProfilerOutput::Mini, nil)
  31
+    mini_cmd = "system_profiler -xml -detailLevel mini SPParallelATAData SPAudioData SPBluetoothData"
  32
+    mini_cmd += " SPCardReaderData SPDiagnosticsData SPDiscBurningData SPEthernetData SPFibreChannelData"
  33
+    mini_cmd += " SPFireWireData SPDisplaysData SPHardwareRAIDData SPMemoryData SPModemData SPNetworkData"
  34
+    mini_cmd += " SPPCIData SPParallelSCSIData SPPrintersSoftwareData SPPrintersData SPSASData SPSerialATAData"
  35
+    mini_cmd += " SPSoftwareData SPThunderboltData SPUSBData SPWWANData SPAirPortData"
  36
+    full_cmd = "system_profiler -xml -detailLevel full SPHardwareDataType"
  37
+    @ohai.stub!(:popen4).with(full_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Full), nil)
  38
+    @ohai.stub!(:popen4).with(mini_cmd).and_yield(nil, StringIO.new, StringIO.new(SystemProfilerOutput::Mini), nil)
33 39
     @ohai._require_plugin("darwin::system_profiler")
34  
-    require 'pp'
35  
-    pp @ohai['system_profile']
36  
-    @ohai['system_profile'][10]["_items"][0]["serial_number"].should == 'ABCDEFG12345'
  40
+    @ohai['system_profile'][18]["_items"][0]["serial_number"].should == 'ABCDEFG12345'
37 41
   end
38 42
 end

0 notes on commit fb1c5ab

Please sign in to comment.
Something went wrong with that request. Please try again.