summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-04-21 15:35:34 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-04-21 15:35:34 -0700
commit16ee59c619a0f40f17b9c64a0e2be6a19140df9d (patch)
treee858cf9c92428c54d15e16d2e8136643bab2d797 /spec
parent30a1b6b918902fa526ed77c185a2928cb2a3f640 (diff)
downloadchef-zero-16ee59c619a0f40f17b9c64a0e2be6a19140df9d.tar.gz
Add ability to run specs against existing Chef::ChefFS
Diffstat (limited to 'spec')
-rw-r--r--spec/run.rb28
1 files changed, 9 insertions, 19 deletions
diff --git a/spec/run.rb b/spec/run.rb
index d538c2f..768e0a0 100644
--- a/spec/run.rb
+++ b/spec/run.rb
@@ -8,12 +8,12 @@ require 'rspec/core'
tmpdir = nil
def start_server(chef_repo_path)
- # Create the chef repo
- Dir.mkdir(chef_repo_path)
+ Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path)
+
# 11.6 and below had a bug where it couldn't create the repo children automatically
if Chef::VERSION.to_f < 11.8
%w(clients cookbooks data_bags environments nodes roles users).each do |child|
- Dir.mkdir("#{chef_repo_path}/#{child}")
+ Dir.mkdir("#{chef_repo_path}/#{child}") if !File.exists?("#{chef_repo_path}/#{child}")
end
end
@@ -22,7 +22,7 @@ def start_server(chef_repo_path)
Chef::Config.chef_repo_path = chef_repo_path
chef_fs = Chef::ChefFS::Config.new.local_fs
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs)
- server = ChefZero::Server.new(:port => 8889, :data_store => data_store)
+ server = ChefZero::Server.new(:port => 8889, :data_store => data_store)#, :log_level => :debug)
server.start_background
server
end
@@ -38,21 +38,9 @@ begin
# Create chef repository
tmpdir = Dir.mktmpdir
chef_repo_path = "#{tmpdir}/repo"
- server = start_server(chef_repo_path)
-
- # Delete everything before each test
- RSpec.configure do |config|
- config.before(:each) do
- # Stop the old server
- if server
- server.stop
- server = nil
- FileUtils.rm_rf(chef_repo_path)
- end
- server = start_server(chef_repo_path)
- end
- end
+ # Capture setup data into master_chef_repo_path
+ server = start_server(chef_repo_path)
else
server = ChefZero::Server.new(:port => 8889)
@@ -63,6 +51,8 @@ begin
require 'pedant'
require 'pedant/opensource'
+ #Pedant::Config.rerun = true
+
Pedant.config.suite = 'api'
Pedant.config[:config_file] = 'spec/support/pedant.rb'
Pedant.setup([
@@ -85,7 +75,7 @@ begin
end
end
- server.stop
+ server.stop if server.running?
ensure
FileUtils.remove_entry_secure(tmpdir) if tmpdir
end