Browse files

Refactor unit test layout

Set up spec tree like chef, to add room for other tests and make room
for support files.

Also include platform helpers from Chef to use as exclusions.
  • Loading branch information...
1 parent 6e39063 commit 0aa6418ee0a19690953811320c30622e7351c27b @btm btm committed Dec 6, 2012
Showing with 44 additions and 1 deletion.
  1. +13 −1 spec/spec_helper.rb
  2. +31 −0 spec/support/platform_helpers.rb
  3. 0 spec/{ohai → unit}/mixin/command_spec.rb
  4. 0 spec/{ohai → unit}/mixin/from_file_spec.rb
  5. 0 spec/{ohai → unit}/plugins/c_spec.rb
  6. 0 spec/{ohai → unit}/plugins/chef_spec.rb
  7. 0 spec/{ohai → unit}/plugins/cloud_spec.rb
  8. 0 spec/{ohai → unit}/plugins/darwin/hostname_spec.rb
  9. 0 spec/{ohai → unit}/plugins/darwin/kernel_spec.rb
  10. 0 spec/{ohai → unit}/plugins/darwin/network_spec.rb
  11. 0 spec/{ohai → unit}/plugins/darwin/platform_spec.rb
  12. 0 spec/{ohai → unit}/plugins/darwin/system_profiler_output.rb
  13. 0 spec/{ohai → unit}/plugins/darwin/system_profiler_spec.rb
  14. 0 spec/{ohai → unit}/plugins/dmi_spec.rb
  15. 0 spec/{ohai → unit}/plugins/ec2_spec.rb
  16. 0 spec/{ohai → unit}/plugins/erlang_spec.rb
  17. 0 spec/{ohai → unit}/plugins/eucalyptus_spec.rb
  18. 0 spec/{ohai → unit}/plugins/fail_spec.rb
  19. 0 spec/{ohai → unit}/plugins/freebsd/hostname_spec.rb
  20. 0 spec/{ohai → unit}/plugins/freebsd/kernel_spec.rb
  21. 0 spec/{ohai → unit}/plugins/freebsd/platform_spec.rb
  22. 0 spec/{ohai → unit}/plugins/freebsd/virtualization_spec.rb
  23. 0 spec/{ohai → unit}/plugins/groovy_spec.rb
  24. 0 spec/{ohai → unit}/plugins/hostname_spec.rb
  25. 0 spec/{ohai → unit}/plugins/java_spec.rb
  26. 0 spec/{ohai → unit}/plugins/kernel_spec.rb
  27. 0 spec/{ohai → unit}/plugins/linode_spec.rb
  28. 0 spec/{ohai → unit}/plugins/linux/cpu_spec.rb
  29. 0 spec/{ohai → unit}/plugins/linux/filesystem_spec.rb
  30. 0 spec/{ohai → unit}/plugins/linux/hostname_spec.rb
  31. 0 spec/{ohai → unit}/plugins/linux/kernel_spec.rb
  32. 0 spec/{ohai → unit}/plugins/linux/lsb_spec.rb
  33. 0 spec/{ohai → unit}/plugins/linux/network_spec.rb
  34. 0 spec/{ohai → unit}/plugins/linux/platform_spec.rb
  35. 0 spec/{ohai → unit}/plugins/linux/uptime_spec.rb
  36. 0 spec/{ohai → unit}/plugins/linux/virtualization_spec.rb
  37. 0 spec/{ohai → unit}/plugins/lua_spec.rb
  38. 0 spec/{ohai → unit}/plugins/mono_spec.rb
  39. 0 spec/{ohai → unit}/plugins/netbsd/hostname_spec.rb
  40. 0 spec/{ohai → unit}/plugins/netbsd/kernel_spec.rb
  41. 0 spec/{ohai → unit}/plugins/netbsd/platform_spec.rb
  42. 0 spec/{ohai → unit}/plugins/network_spec.rb
  43. 0 spec/{ohai → unit}/plugins/nodejs_spec.rb
  44. 0 spec/{ohai → unit}/plugins/ohai_spec.rb
  45. 0 spec/{ohai → unit}/plugins/ohai_time_spec.rb
  46. 0 spec/{ohai → unit}/plugins/openbsd/hostname_spec.rb
  47. 0 spec/{ohai → unit}/plugins/openbsd/kernel_spec.rb
  48. 0 spec/{ohai → unit}/plugins/openbsd/platform_spec.rb
  49. 0 spec/{ohai → unit}/plugins/os_spec.rb
  50. 0 spec/{ohai → unit}/plugins/passwd_spec.rb
  51. 0 spec/{ohai → unit}/plugins/perl_spec.rb
  52. 0 spec/{ohai → unit}/plugins/php_spec.rb
  53. 0 spec/{ohai → unit}/plugins/platform_spec.rb
  54. 0 spec/{ohai → unit}/plugins/python_spec.rb
  55. 0 spec/{ohai → unit}/plugins/rackspace_spec.rb
  56. 0 spec/{ohai → unit}/plugins/ruby_spec.rb
  57. 0 spec/{ohai → unit}/plugins/sigar/network_route_spec.rb
  58. 0 spec/{ohai → unit}/plugins/solaris2/hostname_spec.rb
  59. 0 spec/{ohai → unit}/plugins/solaris2/kernel_spec.rb
  60. 0 spec/{ohai → unit}/plugins/solaris2/network_spec.rb
  61. 0 spec/{ohai → unit}/plugins/solaris2/platform_spec.rb
  62. 0 spec/{ohai → unit}/plugins/solaris2/virtualization_spec.rb
  63. 0 spec/{ohai → unit}/plugins/ssh_host_keys_spec.rb
  64. 0 spec/{ohai → unit}/system_spec.rb
View
14 spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rspec'
-require 'mixlib/config'
+
+require 'spec/support/platform_helpers'
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'ohai'
@@ -54,3 +55,14 @@ def from_file(filename)
self.instance_eval(IO.read(filename), filename, 1)
end
end
+
+RSpec.configure do |config|
+ config.treat_symbols_as_metadata_keys_with_true_values = true
+
+ config.filter_run_excluding :windows_only => true unless windows?
+ config.filter_run_excluding :unix_only => true unless unix?
+ config.filter_run_excluding :ruby_18_only => true unless ruby_18?
+ config.filter_run_excluding :ruby_19_only => true unless ruby_19?
+ config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root'
+ config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
+end
View
31 spec/support/platform_helpers.rb
@@ -0,0 +1,31 @@
+def ruby_19?
+ !!(RUBY_VERSION =~ /^1.9/)
+end
+
+def ruby_18?
+ !!(RUBY_VERSION =~ /^1.8/)
+end
+
+def windows?
+ !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
+end
+
+# def jruby?
+
+def unix?
+ !windows?
+end
+
+def os_x?
+ !!(RUBY_PLATFORM =~ /darwin/)
+end
+
+def solaris?
+ !!(RUBY_PLATFORM =~ /solaris/)
+end
+
+def freebsd?
+ !!(RUBY_PLATFORM =~ /freebsd/)
+end
+
+DEV_NULL = windows? ? 'NUL' : '/dev/null'
View
0 spec/ohai/mixin/command_spec.rb → spec/unit/mixin/command_spec.rb
File renamed without changes.
View
0 spec/ohai/mixin/from_file_spec.rb → spec/unit/mixin/from_file_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/c_spec.rb → spec/unit/plugins/c_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/chef_spec.rb → spec/unit/plugins/chef_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/cloud_spec.rb → spec/unit/plugins/cloud_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/darwin/hostname_spec.rb → spec/unit/plugins/darwin/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/darwin/kernel_spec.rb → spec/unit/plugins/darwin/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/darwin/network_spec.rb → spec/unit/plugins/darwin/network_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/darwin/platform_spec.rb → spec/unit/plugins/darwin/platform_spec.rb
File renamed without changes.
View
0 .../plugins/darwin/system_profiler_output.rb → .../plugins/darwin/system_profiler_output.rb
File renamed without changes.
View
0 ...ai/plugins/darwin/system_profiler_spec.rb → ...it/plugins/darwin/system_profiler_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/dmi_spec.rb → spec/unit/plugins/dmi_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/ec2_spec.rb → spec/unit/plugins/ec2_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/erlang_spec.rb → spec/unit/plugins/erlang_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/eucalyptus_spec.rb → spec/unit/plugins/eucalyptus_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/fail_spec.rb → spec/unit/plugins/fail_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/freebsd/hostname_spec.rb → spec/unit/plugins/freebsd/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/freebsd/kernel_spec.rb → spec/unit/plugins/freebsd/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/freebsd/platform_spec.rb → spec/unit/plugins/freebsd/platform_spec.rb
File renamed without changes.
View
0 ...ai/plugins/freebsd/virtualization_spec.rb → ...it/plugins/freebsd/virtualization_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/groovy_spec.rb → spec/unit/plugins/groovy_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/hostname_spec.rb → spec/unit/plugins/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/java_spec.rb → spec/unit/plugins/java_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/kernel_spec.rb → spec/unit/plugins/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linode_spec.rb → spec/unit/plugins/linode_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/cpu_spec.rb → spec/unit/plugins/linux/cpu_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/filesystem_spec.rb → spec/unit/plugins/linux/filesystem_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/hostname_spec.rb → spec/unit/plugins/linux/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/kernel_spec.rb → spec/unit/plugins/linux/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/lsb_spec.rb → spec/unit/plugins/linux/lsb_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/network_spec.rb → spec/unit/plugins/linux/network_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/platform_spec.rb → spec/unit/plugins/linux/platform_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/linux/uptime_spec.rb → spec/unit/plugins/linux/uptime_spec.rb
File renamed without changes.
View
0 ...ohai/plugins/linux/virtualization_spec.rb → ...unit/plugins/linux/virtualization_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/lua_spec.rb → spec/unit/plugins/lua_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/mono_spec.rb → spec/unit/plugins/mono_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/netbsd/hostname_spec.rb → spec/unit/plugins/netbsd/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/netbsd/kernel_spec.rb → spec/unit/plugins/netbsd/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/netbsd/platform_spec.rb → spec/unit/plugins/netbsd/platform_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/network_spec.rb → spec/unit/plugins/network_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/nodejs_spec.rb → spec/unit/plugins/nodejs_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/ohai_spec.rb → spec/unit/plugins/ohai_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/ohai_time_spec.rb → spec/unit/plugins/ohai_time_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/openbsd/hostname_spec.rb → spec/unit/plugins/openbsd/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/openbsd/kernel_spec.rb → spec/unit/plugins/openbsd/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/openbsd/platform_spec.rb → spec/unit/plugins/openbsd/platform_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/os_spec.rb → spec/unit/plugins/os_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/passwd_spec.rb → spec/unit/plugins/passwd_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/perl_spec.rb → spec/unit/plugins/perl_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/php_spec.rb → spec/unit/plugins/php_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/platform_spec.rb → spec/unit/plugins/platform_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/python_spec.rb → spec/unit/plugins/python_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/rackspace_spec.rb → spec/unit/plugins/rackspace_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/ruby_spec.rb → spec/unit/plugins/ruby_spec.rb
File renamed without changes.
View
0 .../ohai/plugins/sigar/network_route_spec.rb → .../unit/plugins/sigar/network_route_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/solaris2/hostname_spec.rb → spec/unit/plugins/solaris2/hostname_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/solaris2/kernel_spec.rb → spec/unit/plugins/solaris2/kernel_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/solaris2/network_spec.rb → spec/unit/plugins/solaris2/network_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/solaris2/platform_spec.rb → spec/unit/plugins/solaris2/platform_spec.rb
File renamed without changes.
View
0 ...i/plugins/solaris2/virtualization_spec.rb → ...t/plugins/solaris2/virtualization_spec.rb
File renamed without changes.
View
0 spec/ohai/plugins/ssh_host_keys_spec.rb → spec/unit/plugins/ssh_host_keys_spec.rb
File renamed without changes.
View
0 spec/ohai/system_spec.rb → spec/unit/system_spec.rb
File renamed without changes.

0 comments on commit 0aa6418

Please sign in to comment.