aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authormansimarkaur2017-07-31 22:30:36 +0530
committermansimarkaur2017-08-27 01:23:32 +0530
commit4f0f55a7748b1fd477937d2e9c48a45f754ac725 (patch)
tree85dac1abf9b0066566876bf18e491014aa4bce70 /Library
parent660617a35b81ccb223682f2267cd641d7baf31c6 (diff)
downloadbrew-4f0f55a7748b1fd477937d2e9c48a45f754ac725.tar.bz2
Used system command to run git commands
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/utils/git_spec.rb41
1 files changed, 23 insertions, 18 deletions
diff --git a/Library/Homebrew/test/utils/git_spec.rb b/Library/Homebrew/test/utils/git_spec.rb
index 37ca331e3..46c8b1e4f 100644
--- a/Library/Homebrew/test/utils/git_spec.rb
+++ b/Library/Homebrew/test/utils/git_spec.rb
@@ -6,16 +6,18 @@ describe Git do
file = "lib/blah.rb"
repo = Pathname.new("repo")
FileUtils.mkpath("repo/lib")
- `#{git} init`
- FileUtils.touch("repo/#{file}")
- File.open(repo.to_s+"/"+file, "w") { |f| f.write("blah") }
- `#{git} add repo/#{file}`
- `#{git} commit -m"File added"`
- @hash1 = `git rev-parse HEAD`
- File.open(repo.to_s+"/"+file, "w") { |f| f.write("brew") }
- `#{git} add repo/#{file}`
- `#{git} commit -m"written to File"`
- @hash2 = `git rev-parse HEAD`
+ shutup do
+ system "#{git} init"
+ FileUtils.touch("repo/#{file}")
+ File.open(repo.join("file").to_s, "w") { |f| f.write("blah") }
+ system "#{git} add repo/#{file}"
+ system "#{git} commit -m'File added'"
+ @hash1 = `git rev-parse HEAD`
+ File.open(repo.join("file").to_s, "w") { |f| f.write("brew") }
+ system "#{git} add repo/#{file}"
+ system "#{git} commit -m'written to File'"
+ @hash2 = `git rev-parse HEAD`
+ end
end
let(:file) { "lib/blah.rb" }
@@ -37,11 +39,11 @@ describe Git do
describe "#last_revision_of_file" do
it "returns last revision of file" do
- expect(described_class.last_revision_of_file(repo, repo.to_s+"/"+file)).to eq("blah")
+ expect(described_class.last_revision_of_file(repo, repo.join("file").to_s)).to eq("blah")
end
it "returns last revision of file based on before_commit" do
- expect(described_class.last_revision_of_file(repo, repo.to_s+"/"+file, before_commit: "0..3")).to eq("brew")
+ expect(described_class.last_revision_of_file(repo, repo.join("file").to_s, before_commit: "0..3")).to eq("brew")
end
end
end
@@ -82,7 +84,8 @@ describe Utils do
end
it "returns path of git" do
- expect(described_class.git_path).to eq("/Applications/Xcode.app/Contents/Developer/usr/bin/git")
+ allow(Utils).to receive(popen_read).with(HOMEBREW_SHIMS_PATH/"scm/git", "--homebrew=print-path").and_return("git")
+ expect(described_class.git_path).to eq("git")
end
it "returns git_path if already set" do
@@ -99,7 +102,7 @@ describe Utils do
described_class.instance_variable_set(:@git, false)
end
- it "returns" do
+ it "returns nil" do
expect(described_class.git_path).to eq(nil)
end
end
@@ -138,10 +141,12 @@ describe Utils do
git = HOMEBREW_SHIMS_PATH/"scm/git"
@repo = Pathname.new("hey")
FileUtils.mkpath("hey")
- `cd #{@repo}`
- `#{git} init`
- `#{git} remote add origin git@github.com:Homebrew/brew`
- `cd ..`
+ shutup do
+ system "cd #{@repo}"
+ system "#{git} init"
+ system "#{git} remote add origin git@github.com:Homebrew/brew"
+ system "cd .."
+ end
end
after(:all) do