summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-07-29 17:13:14 -0700
committerdanielsdeleo <dan@opscode.com>2013-08-02 09:29:04 -0700
commitb1819c306382fabece4a0d1ed9343590967bc775 (patch)
treee746768af92279cc431bc07755cf92a9192a2eef /spec/spec_helper.rb
parent4dcf3ee63fe759dbb573539e2f0f61329a61125c (diff)
downloadchef-b1819c306382fabece4a0d1ed9343590967bc775.tar.gz
Add provider based test filters for functional tests
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 524cc38450..7cecaf8172 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -83,6 +83,11 @@ Dir["spec/support/**/*.rb"].
map { |f| f.gsub(%r[spec/], '')}.
each { |f| require f }
+
+OHAI_SYSTEM = Ohai::System.new
+OHAI_SYSTEM.require_plugin("os")
+OHAI_SYSTEM.require_plugin("platform")
+
RSpec.configure do |config|
config.include(Matchers)
config.filter_run :focus => true
@@ -111,6 +116,17 @@ 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 = OHAI_SYSTEM["platform"],
+ platform_version = OHAI_SYSTEM["platform_version"]
+ provider_for_running_platform = Chef::Platform.find_provider(platform, platform_version, type)
+ provider_for_running_platform != target_provider
+ }
+
config.run_all_when_everything_filtered = true
config.treat_symbols_as_metadata_keys_with_true_values = true
end