summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-08-18 13:38:31 -0700
committerSerdar Sutay <serdar@opscode.com>2014-08-18 13:38:31 -0700
commit8bd2466f1d4a05f2e6f26e3fc5bf78865d8e4363 (patch)
tree60a02d651267e0a06b56f868bbcaa4b8a1deda2d
parent35e7c075da4d0d57e941bb6a6d81be8e018f2f41 (diff)
downloadchef-8bd2466f1d4a05f2e6f26e3fc5bf78865d8e4363.tar.gz
Disable functional dscl specs on non-mac OSes.
-rw-r--r--chef/spec/spec_helper.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/chef/spec/spec_helper.rb b/chef/spec/spec_helper.rb
index 733584866c..de6a7811a3 100644
--- a/chef/spec/spec_helper.rb
+++ b/chef/spec/spec_helper.rb
@@ -51,6 +51,13 @@ require 'spec/support/local_gems.rb' if File.exists?(File.join(File.dirname(__FI
# Explicitly require spec helpers that need to load first
require 'spec/support/platform_helpers'
+
+OHAI_SYSTEM = Ohai::System.new
+OHAI_SYSTEM.require_plugin("os")
+OHAI_SYSTEM.require_plugin("platform")
+TEST_PLATFORM = OHAI_SYSTEM["platform"].dup.freeze
+TEST_PLATFORM_VERSION = OHAI_SYSTEM["platform_version"].dup.freeze
+
# Autoloads support files
# Excludes support/platforms by default
# Do not change the gsub.
@@ -81,6 +88,22 @@ RSpec.configure do |config|
config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
config.filter_run_excluding :uses_diff => true unless has_diff?
+ # Functional Resource tests that are provider-specific:
+ # context "on platforms that use useradd", :provider => {:user => Chef::Provider::User::Useradd}} do #...
+ config.filter_run_excluding :provider => lambda {|criteria|
+ type, target_provider = criteria.first
+
+ platform = TEST_PLATFORM.dup
+ platform_version = TEST_PLATFORM_VERSION.dup
+
+ begin
+ provider_for_running_platform = Chef::Platform.find_provider(platform, platform_version, type)
+ provider_for_running_platform != target_provider
+ rescue ArgumentError # no provider for platform
+ true
+ end
+ }
+
config.run_all_when_everything_filtered = true
config.treat_symbols_as_metadata_keys_with_true_values = true
end