features/support/env.rb in lolcommits-0.5.7 vs features/support/env.rb in lolcommits-0.5.8.pre1

- old
+ new

@@ -1,88 +1,58 @@ # -*- encoding : utf-8 -*- require 'aruba/cucumber' require 'methadone/cucumber' require 'open3' -require 'test/unit/assertions' -include Test::Unit::Assertions require 'ffaker' -require 'lolcommits/configuration' +require 'fileutils' + require File.join(File.expand_path(File.dirname(__FILE__)), 'path_helpers') include Lolcommits -ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}" -LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib') - World(PathHelpers) Before do # Using "announce" causes massive warnings on 1.9.2 @puts = true @aruba_timeout_seconds = 20 - @original_rubylib = ENV['RUBYLIB'] - ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s + set_env 'LOLCOMMITS_FAKECAPTURE', '1' + set_env 'LAUNCHY_DRY_RUN', 'true' - @original_fakecapture = ENV['LOLCOMMITS_FAKECAPTURE'] - ENV['LOLCOMMITS_FAKECAPTURE'] = '1' - - # @original_loldir = ENV['LOLCOMMITS_DIR'] - # ENV['LOLCOMMITS_DIR'] = File.expand_path( File.join(current_dir, ".lolcommits") ) - - @original_home = ENV['HOME'] - ENV['HOME'] = File.expand_path(current_dir) - - ENV['LAUNCHY_DRY_RUN'] = 'true' + author_name = 'Testy McTesterson' + author_email = 'testy@tester.com' + set_env 'GIT_AUTHOR_NAME', author_name + set_env 'GIT_COMMITTER_NAME', author_name + set_env 'GIT_AUTHOR_EMAIL', author_email + set_env 'GIT_COMMITTER_EMAIL', author_email end -After do - ENV['RUBYLIB'] = @original_rubylib - ENV['LOLCOMMITS_FAKECAPTURE'] = @original_fakecapture - # ENV['LOLCOMMITS_DIR'] = @original_loldir - ENV['HOME'] = @original_home - ENV['LAUNCHY_DRY_RUN'] = nil - ENV['LOLCOMMITS_FAKEPLATFORM'] = nil -end - -Before('@fake-interactive-rebase') do - # in order to fake an interactive rebase, - # we replace the editor with a script that simply squashes a few random commits - @original_git_editor = ENV['GIT_EDITOR'] - # ENV['GIT_EDITOR'] = "sed -i -e 'n;s/pick/squash/g'" #every other commit - ENV['GIT_EDITOR'] = "sed -i -e '3,5 s/pick/squash/g'" # lines 3-5 -end - -After('@fake-interactive-rebase') do - ENV['GIT_EDITOR'] = @original_git_editor -end - +# for tasks that may take an insanely long time (e.g. network related) +# we should strive to not have any of these in our scenarios, naturally. Before('@slow_process') do @aruba_io_wait_seconds = 5 @aruba_timeout_seconds = 60 end +# in order to fake an interactive rebase, we replace the editor with a script +# to simply squash a few random commits. in this case, using lines 3-5. +Before('@fake-interactive-rebase') do + set_env 'GIT_EDITOR', "sed -i -e '3,5 s/pick/squash/g'" +end + # adjust the path so tests dont see a global imagemagick install Before('@fake-no-imagemagick') do reject_paths_with_cmd('mogrify') end -After('@fake-no-imagemagick') do - reset_path -end - # adjust the path so tests dont see a global ffmpeg install Before('@fake-no-ffmpeg') do reject_paths_with_cmd('ffmpeg') end -After('@fake-no-ffmpeg') do - reset_path -end - # do test in temporary directory so our own git repo-ness doesn't affect it Before('@in-tempdir') do @dirs = [Dir.mktmpdir] end - After('@in-tempdir') do FileUtils.rm_rf(@dirs.first) end