From 5b1c4193eaf4beb3d3457cfb67042e67e84ffe8a Mon Sep 17 00:00:00 2001 From: Claire McQuin Date: Tue, 29 Apr 2014 09:01:59 -0700 Subject: [PATCH] tests don't write to spec/unit --- spec/test_helpers.rb | 5 ++++- spec/unit/command/generator_commands_spec.rb | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/test_helpers.rb b/spec/test_helpers.rb index d70b79d1d..835e1d8fe 100644 --- a/spec/test_helpers.rb +++ b/spec/test_helpers.rb @@ -16,6 +16,7 @@ # require 'fileutils' +require 'tmpdir' module TestHelpers @@ -48,9 +49,11 @@ def reset_tempdir def clear_tempdir FileUtils.rm_rf(tempdir) + @tmpdir = nil end def tempdir - File.join(project_root, "spec/unit/specs-tmpdir" ) + @tmpdir ||= Dir.mktmpdir("chef-dk") + File.realpath(@tmpdir) end end diff --git a/spec/unit/command/generator_commands_spec.rb b/spec/unit/command/generator_commands_spec.rb index 4a9bb9a60..4bd78d9ef 100644 --- a/spec/unit/command/generator_commands_spec.rb +++ b/spec/unit/command/generator_commands_spec.rb @@ -225,6 +225,7 @@ def generator_context before do ChefDK::Generator.reset + reset_tempdir end context "when argv is empty" do @@ -243,7 +244,6 @@ def generator_context let(:argv) { [ new_file_name ] } before do - reset_tempdir FileUtils.cp_r(File.join(fixtures_path, "example_cookbook"), tempdir) end @@ -288,6 +288,10 @@ def generator_context context "and path to the cookbook is given in the argv" do let(:argv) { [cookbook_path, new_file_name ] } + before do + FileUtils.cp_r(File.join(fixtures_path, "example_cookbook"), tempdir) + end + it "configures the generator context" do recipe_generator.read_and_validate_params recipe_generator.setup_context