spec/spec_helper.rb in git-topic-0.2.3.1 vs spec/spec_helper.rb in git-topic-0.2.3.2
- old
+ new
@@ -1,10 +1,11 @@
# encoding: utf-8
require 'fileutils'
require 'git_topic'
+require 'git_topic/cli'
# Testing-specific monkeypatching # {{{
# Disable caching on GitTopic for specs since we're calling the methods directly
@@ -103,11 +104,11 @@
FileUtils.mv ".git/refs/notes/reviews/USER",
".git/refs/notes/reviews/#{@user}"
end
Dir.chdir @starting_dir
end
- Dir.chdir './tmp'
+ Dir.chdir "#{@starting_dir}/tmp"
# capture output
@output = ''
@err = ''
$stdout.stub!( :write ) { |*args| @output.<<( *args )}
@@ -125,14 +126,18 @@
# helpers # {{{
def use_repo( repo )
Dir.chdir( repo )
# Exit if e.g. GIT_DIR is set
- raise "Spec error" unless `git rev-parse --git-dir`.chomp == '.git'
+ raise "Spec error" unless git_dir == '.git'
end
+def git_dir
+ `git rev-parse --git-dir 2> /dev/null`.chomp
+end
+
def git_branch
all_branches = `git branch --no-color`.split( "\n" )
current_branch = all_branches.find{|b| b =~ /^\*/}
current_branch[ 2..-1 ] unless current_branch.nil?
@@ -186,9 +191,18 @@
def dirty_branch!
File.open( 'dirty', 'w' ){|f| f.puts "some content" }
system "git add -N dirty"
+end
+
+
+def with_argv( val )
+ restore = ARGV.dup
+ ARGV.replace( val )
+ rv = yield
+ ARGV.replace( restore )
+ rv
end
# }}}