summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Ball <tyleraball@gmail.com>2014-11-05 15:17:35 -0800
committerTyler Ball <tyleraball@gmail.com>2014-11-05 15:17:35 -0800
commit4cbd874d0beba920e24ab4b533461d3844405bd9 (patch)
tree6b8529425c6fc494a79842633b3c58e2cd3030fb
parent3740911b34c0a25831d3031dc1262a4fafed8b2e (diff)
parentb2405643524cdfba8c9adf8e21326a31613c58d2 (diff)
downloadchef-4cbd874d0beba920e24ab4b533461d3844405bd9.tar.gz
Merge pull request #2354 from opscode/mcquin/serverspec
Add serverspec types and matchers.
-rw-r--r--chef.gemspec10
-rw-r--r--lib/chef/audit.rb9
-rw-r--r--lib/chef/audit/chef_example_group.rb1
-rw-r--r--lib/chef/audit/runner.rb7
-rw-r--r--lib/chef/dsl/audit.rb4
5 files changed, 21 insertions, 10 deletions
diff --git a/chef.gemspec b/chef.gemspec
index 16d11d39e5..c5999e494b 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -35,16 +35,16 @@ Gem::Specification.new do |s|
s.add_dependency 'plist', '~> 3.1.0'
+ %w(rspec-core rspec-expectations rspec-mocks).each { |gem| s.add_dependency gem, "~> 3.1" }
+ s.add_dependency "rspec_junit_formatter", "~> 0.2.0"
+ s.add_dependency "serverspec", "~> 2.3"
+ s.add_dependency "specinfra", "~> 2.4"
+
s.add_development_dependency "rack"
# Rake 10.2 drops Ruby 1.8 support
s.add_development_dependency "rake", "~> 10.1.0"
- # rspec_junit_formatter 0.2.0 drops ruby 1.8.7 support
- s.add_development_dependency "rspec_junit_formatter", "~> 0.2.0"
-
- %w(rspec-core rspec-expectations rspec-mocks).each { |gem| s.add_development_dependency gem, "~> 3.1" }
-
s.bindir = "bin"
# chef-service-manager is a windows only executable.
# However gemspec doesn't give us a way to have this executable only
diff --git a/lib/chef/audit.rb b/lib/chef/audit.rb
index 43d5c11ee8..9d0a2a70ed 100644
--- a/lib/chef/audit.rb
+++ b/lib/chef/audit.rb
@@ -16,7 +16,14 @@
# limitations under the License.
#
-require 'rspec/core'
+require 'rspec'
+require 'rspec/its'
+
+require 'serverspec/matcher'
+require 'serverspec/helper'
+require 'serverspec/subject'
+
+require 'specinfra'
require 'chef/dsl/audit'
require 'chef/audit/chef_json_formatter'
diff --git a/lib/chef/audit/chef_example_group.rb b/lib/chef/audit/chef_example_group.rb
index cd874d57b7..482647cd03 100644
--- a/lib/chef/audit/chef_example_group.rb
+++ b/lib/chef/audit/chef_example_group.rb
@@ -1,4 +1,3 @@
-require 'rspec/core'
class Chef
class Audit
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index e3699266b8..0f439a1aa5 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -62,6 +62,7 @@ class Chef
add_formatters
disable_should_syntax
+ configure_specinfra
end
def add_formatters
@@ -82,6 +83,12 @@ class Chef
end
end
+ def configure_specinfra
+ # TODO: We may need to change this based on operating system (there is a
+ # powershell backend) or roll our own.
+ Specinfra.configuration.backend = :exec
+ end
+
# Register each controls group with the world, which will handle
# the ordering of the audits that will be run.
def register_controls_groups
diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb
index 948db72921..6442a37969 100644
--- a/lib/chef/dsl/audit.rb
+++ b/lib/chef/dsl/audit.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-#require 'chef/audit'
+
require 'chef/audit/chef_example_group'
class Chef
@@ -25,8 +25,6 @@ class Chef
# Adds the controls group and block (containing controls to execute) to the runner's list of pending examples
def controls(group_name, &group_block)
raise ::Chef::Exceptions::NoAuditsProvided unless group_block
-
- # TODO add the @example_groups list to the runner for later execution
run_context.controls_groups << ::Chef::Audit::ChefExampleGroup.describe(group_name, &group_block)
end