spec/spec_helper.rb in rubygems-tasks-0.2.4 vs spec/spec_helper.rb in rubygems-tasks-0.2.5

- old
+ new

@@ -1,12 +1,29 @@ -gem 'rspec', '~> 2.4' require 'rspec' +require 'fileutils' +require 'tmpdir' -PROJECTS_DIR = File.join('data','projects') -PROJECT_DIRS = lambda { |name| File.join(PROJECTS_DIR,name) } +# clear the $RUBYCONSOLE env variable +ENV.delete('RUBYCONSOLE') -unless File.directory?(PROJECTS_DIR) - abort "Please run `rake data:projects` before running the specs!" -end +RSpec.configure do |rspec| + rspec.before(:suite) do + PROJECTS_DIR = Dir.mktmpdir('rubygems-tasks') -# clear the $RUBYCONSOLE env variable -ENV['RUBYCONSOLE'] = nil + Dir[File.join(File.dirname(__FILE__),'projects','*')].each do |src| + dest = File.join(PROJECTS_DIR,File.basename(src)) + + FileUtils.cp_r(src,dest) + Dir.chdir(dest) do + system 'git init -q' + system 'git config --local user.email test@example.com' + system 'git config --local user.name Test' + system 'git add .' + system 'git commit -q -a -m "Initial commit"' + end + end + end + + rspec.after(:suite) do + FileUtils.rm_rf(PROJECTS_DIR) + end +end