spec/lib/new/project_spec.rb in new-0.0.4 vs spec/lib/new/project_spec.rb in new-0.0.5
- old
+ new
@@ -1,17 +1,20 @@
require 'spec_helper'
require 'recursive-open-struct'
describe New::Project do
- let(:template_dir){ File.join(New::TEMP_DIR, 'custom_bar_template') }
- let(:project_dir){ File.join(New::TEMP_DIR, 'new_project') }
+ let(:template_dir){ File.join(@tmp_dir, 'custom_bar_template') }
+ let(:project_dir){ File.join(@tmp_dir, 'new_project') }
let(:project){ New::Project.new(:custom_bar_template, :new_project) }
let(:project_config) { YAML.load(File.open(File.join(project_dir, New::CONFIG_FILE))).deep_symbolize_keys! }
before do
- Dir.chdir New::TEMP_DIR
- FileUtils.cp_r root('spec', 'fixtures', 'custom', 'templates', 'custom_bar_template'), New::TEMP_DIR
+ @tmp_dir = Dir.mktmpdir
+ FileUtils.cp_r root('spec', 'fixtures', 'custom', 'templates', 'custom_bar_template'), @tmp_dir
New::Template.stub(:new).and_return(RecursiveOpenStruct.new({ options: {}, dir: template_dir }))
+
+ # change directory before creating a project since it uses pwd
+ Dir.chdir @tmp_dir
project
end
after do
New::Template.unstub(:new)