Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add adding integration specs and some crappy helpers
- Loading branch information
1 parent
21b6608
commit 0d77e1e
Showing
3 changed files
with
175 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require File.dirname(__FILE__) + '/../integration_helper' | ||
|
||
describe "Adding a mirror in a clean repository" do | ||
|
||
before do | ||
FileUtils.rm_rf(TMP_PATH) | ||
FileUtils.mkdir_p(TMP_PATH) | ||
end | ||
|
||
|
||
describe "from a git repository" do | ||
before do | ||
@shiny = create_git_repo_from_fixture("shiny") | ||
@skit1 = create_git_repo_from_fixture("skit1") | ||
end | ||
|
||
it "should add the files and commit" do | ||
in_dir(@shiny) do | ||
`braid add --type git #{@skit1}` | ||
end | ||
|
||
file_name = "skit1/layouts/layout.liquid" | ||
output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}` | ||
$?.should.be.success | ||
|
||
output = `git log --pretty=oneline`.split("\n") | ||
output.length.should == 2 | ||
output[0].should =~ "Add mirror 'skit1/'" | ||
end | ||
end | ||
|
||
describe "from an svn repository" do | ||
before do | ||
@shiny = create_git_repo_from_fixture("shiny") | ||
@skit1 = create_svn_repo_from_fixture("skit1") | ||
end | ||
|
||
it "should add the files and commit" do | ||
in_dir(@shiny) do | ||
`braid add --type svn #{@skit1}` | ||
end | ||
|
||
file_name = "skit1/layouts/layout.liquid" | ||
output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}` | ||
$?.should.be.success | ||
|
||
output = `git log --pretty=oneline`.split("\n") | ||
output.length.should == 2 | ||
output[0].should =~ "Add mirror 'skit1/'" | ||
end | ||
end | ||
|
||
|
||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require 'rubygems' | ||
require 'test/spec' | ||
require 'mocha' | ||
|
||
#require File.dirname(__FILE__) + '/../lib/braid' | ||
|
||
require 'tempfile' | ||
require 'fileutils' | ||
require 'pathname' | ||
|
||
#tmp_file = Tempfile.new("braid") | ||
#tmp_file_path = tmp_file.path | ||
#tmp_file.unlink | ||
#TMP = File.basename(tmp_file_path) | ||
|
||
TMP_PATH = File.join(Dir.tmpdir, "braid_integration") | ||
BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath | ||
FIXTURE_PATH = File.join(BRAID_PATH, "test", "fixtures") | ||
FileUtils.mkdir_p(TMP_PATH) | ||
|
||
#def exec(cmd) | ||
# `cd #{TMP} && #{cmd}` | ||
#end | ||
|
||
def in_dir(dir = TMP_PATH) | ||
Dir.chdir(dir) | ||
yield | ||
end | ||
|
||
def run_cmds(ary) | ||
ary.each do |cmd| | ||
cmd = cmd.strip! | ||
out = `#{cmd}` | ||
end | ||
end | ||
|
||
def create_git_repo_from_fixture(fixture_name) | ||
git_repo = File.join(TMP_PATH, fixture_name) | ||
FileUtils.cp_r(File.join(FIXTURE_PATH, fixture_name), TMP_PATH) | ||
in_dir(git_repo) do | ||
run_cmds(<<-EOD) | ||
git init | ||
git add * | ||
git commit -m "initial commit of #{fixture_name}" | ||
EOD | ||
end | ||
git_repo | ||
end | ||
|
||
def create_svn_repo_from_fixture(fixture_name) | ||
svn_wc = File.join(TMP_PATH, fixture_name + "_repo") | ||
svn_repo = File.join(TMP_PATH, fixture_name) | ||
run_cmds(<<-EOD) | ||
svnadmin create #{svn_repo} | ||
svn co file://#{svn_repo} #{svn_wc} | ||
EOD | ||
FileUtils.cp_r("#{FIXTURE_PATH}/#{fixture_name}/.", svn_wc) | ||
in_dir(svn_wc) do | ||
run_cmds(<<-EOD) | ||
svn add * | ||
svn commit -m "initial commit of #{fixture_name}" | ||
EOD | ||
end | ||
"file://#{svn_repo}" | ||
end | ||
|
||
|