summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmy Unger <amy.e.unger@gmail.com>2015-07-26 20:50:28 -0500
committerAmy Unger <amy.e.unger@gmail.com>2015-07-26 20:50:28 -0500
commitce7fd722a63455d00d2bc0dc5f43e5631c2d1e22 (patch)
treeb45b165aa491ab231a4556ead849a087123a5462
parente650cd4d4acabfa4cc261cdd08b947c93c8208f0 (diff)
downloadbundler-ce7fd722a63455d00d2bc0dc5f43e5631c2d1e22.tar.gz
Use a Bundler specific gitconfig file rather than altering user's files
- Make test suite work with local git configs - Prefer altering environment variable to altering user's ~/.gitconfig file
-rw-r--r--spec/commands/newgem_spec.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index fafc9a5f35..266fd44fc4 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -16,15 +16,20 @@ describe "bundle gem" do
end
before do
- @git_name = `git config --global user.name`.chomp
- `git config --global user.name "Bundler User"`
- @git_email = `git config --global user.email`.chomp
- `git config --global user.email user@example.com`
+ git_config_content = <<-EOF
+ [user]
+ name = "Bundler User"
+ email = user@example.com
+ EOF
+ @git_config_location = ENV["GIT_CONFIG"]
+ path = "#{File.expand_path("../../tmp", File.dirname(__FILE__))}/test_git_config.txt"
+ File.open(path, "w") {|f| f.write(git_config_content) }
+ ENV["GIT_CONFIG"] = path
end
after do
- `git config --global user.name "#{@git_name}"`
- `git config --global user.email "#{@git_email}"`
+ `rm "#{ENV['GIT_CONFIG']}"` if File.exist?(ENV["GIT_CONFIG"])
+ ENV["GIT_CONFIG"] = @git_config_location
end
shared_examples_for "git config is present" do
@@ -156,8 +161,8 @@ describe "bundle gem" do
context "git config user.{name,email} is not set" do
before do
- `git config --global --unset user.name`
- `git config --global --unset user.email`
+ `git config --unset user.name`
+ `git config --unset user.email`
reset!
in_app_root
bundle "gem #{gem_name}"
@@ -406,8 +411,8 @@ describe "bundle gem" do
context "git config user.{name,email} is not set" do
before do
- `git config --global --unset user.name`
- `git config --global --unset user.email`
+ `git config --unset user.name`
+ `git config --unset user.email`
reset!
in_app_root
bundle "gem #{gem_name}"