spec/spec_helper.rb in retter-0.2.5 vs spec/spec_helper.rb in retter-1.0.0.pre

- old
+ new

@@ -1,46 +1,57 @@ # coding: utf-8 require 'tapp' -require 'delorean' +require 'pry' +require 'retter' -if ENV['COVERAGE'] - require 'simplecov' - SimpleCov.start -end +RETTER_GEM_DIR = Pathname.new(File.dirname(__FILE__) + '/../').realpath -RETTER_ROOT = Pathname.new(File.dirname(__FILE__) + '/../').realpath -require RETTER_ROOT.join('lib', 'retter') - Dir[File.dirname(__FILE__) + '/support/*'].each {|f| require f } RSpec.configure do |config| - config.filter_run focus: true config.run_all_when_everything_filtered = true + config.treat_symbols_as_metadata_keys_with_true_values = true + config.order = 'random' - retter_home = RETTER_ROOT.join('tmp/test') - skel = RETTER_ROOT.join('lib/retter/generator/skel') - fake_editor = RETTER_ROOT.join('spec/bin/fake_editor') + config.include Retter::ExampleHelper - config.before :each, clean: :all do - FileUtils.cp_r skel, retter_home.dirname.join('test') + config.before :suite do + Retter::TestSite.tap do |test_site| + test_site.generate_skel 'default' + test_site.generate_skel 'multi_branch' do |site_dir| + Retter::Repository.new site_dir do |repo| + repo.checkout '--orphan', 'source' do + repo.commit '-m', 'Initial' + end + + repo.rm '-r', 'source', 'Retterfile' + repo.commit '-m', 'Remove source files' + end + end + end end - config.after :each, clean: :all do - FileUtils.rm_rf retter_home - - Retter::Site.reset! + config.before :all do + Retter::TestSite.sites_dir.tap do |dir| + dir.rmtree if dir.directory? + end end - config.before :each do - env = {'EDITOR' => fake_editor.to_path, 'RETTER_HOME' => RETTER_ROOT.join('tmp', 'test').to_s} + config.before :each do |example| + Retter::ExampleHelper.remove_retter_env - Retter::Site.load env + ENV['EDITOR'] = RETTER_GEM_DIR.join('spec/bin/fake_editor').to_path end - config.include Delorean - config.after :each do - back_to_the_present + config.around :each, :with_default_site do |example| + Retter::TestSite.create 'default' do |site_dir| + example.run + end end - config.include ExampleGroupHelper + config.around :each, :with_multi_branch_site do |example| + Retter::TestSite.create 'multi_branch' do |site_dir| + example.run + end + end end