Used system command to run git commands
This commit is contained in:
parent
660617a35b
commit
4f0f55a774
@ -6,16 +6,18 @@ describe Git do
|
|||||||
file = "lib/blah.rb"
|
file = "lib/blah.rb"
|
||||||
repo = Pathname.new("repo")
|
repo = Pathname.new("repo")
|
||||||
FileUtils.mkpath("repo/lib")
|
FileUtils.mkpath("repo/lib")
|
||||||
`#{git} init`
|
shutup do
|
||||||
FileUtils.touch("repo/#{file}")
|
system "#{git} init"
|
||||||
File.open(repo.to_s+"/"+file, "w") { |f| f.write("blah") }
|
FileUtils.touch("repo/#{file}")
|
||||||
`#{git} add repo/#{file}`
|
File.open(repo.join("file").to_s, "w") { |f| f.write("blah") }
|
||||||
`#{git} commit -m"File added"`
|
system "#{git} add repo/#{file}"
|
||||||
@hash1 = `git rev-parse HEAD`
|
system "#{git} commit -m'File added'"
|
||||||
File.open(repo.to_s+"/"+file, "w") { |f| f.write("brew") }
|
@hash1 = `git rev-parse HEAD`
|
||||||
`#{git} add repo/#{file}`
|
File.open(repo.join("file").to_s, "w") { |f| f.write("brew") }
|
||||||
`#{git} commit -m"written to File"`
|
system "#{git} add repo/#{file}"
|
||||||
@hash2 = `git rev-parse HEAD`
|
system "#{git} commit -m'written to File'"
|
||||||
|
@hash2 = `git rev-parse HEAD`
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:file) { "lib/blah.rb" }
|
let(:file) { "lib/blah.rb" }
|
||||||
@ -37,11 +39,11 @@ describe Git do
|
|||||||
|
|
||||||
describe "#last_revision_of_file" do
|
describe "#last_revision_of_file" do
|
||||||
it "returns 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
|
end
|
||||||
|
|
||||||
it "returns last revision of file based on before_commit" do
|
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
|
end
|
||||||
end
|
end
|
||||||
@ -82,7 +84,8 @@ describe Utils do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns path of git" do
|
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
|
end
|
||||||
|
|
||||||
it "returns git_path if already set" do
|
it "returns git_path if already set" do
|
||||||
@ -99,7 +102,7 @@ describe Utils do
|
|||||||
described_class.instance_variable_set(:@git, false)
|
described_class.instance_variable_set(:@git, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns" do
|
it "returns nil" do
|
||||||
expect(described_class.git_path).to eq(nil)
|
expect(described_class.git_path).to eq(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -138,10 +141,12 @@ describe Utils do
|
|||||||
git = HOMEBREW_SHIMS_PATH/"scm/git"
|
git = HOMEBREW_SHIMS_PATH/"scm/git"
|
||||||
@repo = Pathname.new("hey")
|
@repo = Pathname.new("hey")
|
||||||
FileUtils.mkpath("hey")
|
FileUtils.mkpath("hey")
|
||||||
`cd #{@repo}`
|
shutup do
|
||||||
`#{git} init`
|
system "cd #{@repo}"
|
||||||
`#{git} remote add origin git@github.com:Homebrew/brew`
|
system "#{git} init"
|
||||||
`cd ..`
|
system "#{git} remote add origin git@github.com:Homebrew/brew"
|
||||||
|
system "cd .."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:all) do
|
after(:all) do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user