Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29 from opscode/non-sudo-tmpdir
Browse files Browse the repository at this point in the history
tests don't write to spec/unit
  • Loading branch information
mcquin committed Apr 29, 2014
2 parents f5418f2 + 5b1c419 commit f3a0b21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion spec/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

require 'fileutils'
require 'tmpdir'

module TestHelpers

Expand Down Expand Up @@ -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
6 changes: 5 additions & 1 deletion spec/unit/command/generator_commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def generator_context

before do
ChefDK::Generator.reset
reset_tempdir
end

context "when argv is empty" do
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3a0b21

Please sign in to comment.