From ce7fd722a63455d00d2bc0dc5f43e5631c2d1e22 Mon Sep 17 00:00:00 2001 From: Amy Unger Date: Sun, 26 Jul 2015 20:50:28 -0500 Subject: 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 --- spec/commands/newgem_spec.rb | 25 +++++++++++++++---------- 1 file 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}" -- cgit v1.2.1 From 1c32a71811bfab307d837483c81cc74e1b1cb0dc Mon Sep 17 00:00:00 2001 From: Amy Unger Date: Sun, 26 Jul 2015 20:50:46 -0500 Subject: Fix style to use double quotes --- spec/commands/newgem_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 266fd44fc4..8acde88b5e 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -28,7 +28,7 @@ describe "bundle gem" do end after do - `rm "#{ENV['GIT_CONFIG']}"` if File.exist?(ENV["GIT_CONFIG"]) + `rm "#{ENV["GIT_CONFIG"]}"` if File.exist?(ENV["GIT_CONFIG"]) ENV["GIT_CONFIG"] = @git_config_location end -- cgit v1.2.1