refactor given_castle

This commit is contained in:
muratayusuke
2013-05-30 17:38:06 +00:00
committed by thilko
parent ed71fd6227
commit aa2dfcc42f
2 changed files with 5 additions and 4 deletions

View File

@@ -123,7 +123,7 @@ describe "homesick" do
end end
context "with '.config' in .homesick_subdir" do context "with '.config' in .homesick_subdir" do
let(:castle) { given_castle("glencairn", "glencairn", [".config"]) } let(:castle) { given_castle("glencairn", [".config"]) }
it "can symlink in sub directory" do it "can symlink in sub directory" do
dotdir = castle.directory(".config") dotdir = castle.directory(".config")
dotfile = dotdir.file(".some_dotfile") dotfile = dotdir.file(".some_dotfile")
@@ -137,7 +137,7 @@ describe "homesick" do
end end
context "with '.config/appA' in .homesick_subdir" do context "with '.config/appA' in .homesick_subdir" do
let(:castle) { given_castle("glencairn", "glencairn", [".config/appA"]) } let(:castle) { given_castle("glencairn", [".config/appA"]) }
it "can symlink in nested sub directory" do it "can symlink in nested sub directory" do
dotdir = castle.directory(".config").directory("appA") dotdir = castle.directory(".config").directory("appA")
dotfile = dotdir.file(".some_dotfile") dotfile = dotdir.file(".some_dotfile")
@@ -154,7 +154,7 @@ describe "homesick" do
describe "list" do describe "list" do
it "should say each castle in the castle directory" do it "should say each castle in the castle directory" do
given_castle('zomg') given_castle('zomg')
given_castle('zomg', 'wtf/zomg') given_castle('wtf/zomg')
homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan) homesick.should_receive(:say_status).with("zomg", "git://github.com/technicalpickles/zomg.git", :cyan)
homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan) homesick.should_receive(:say_status).with("wtf/zomg", "git://github.com/technicalpickles/zomg.git", :cyan)

View File

@@ -16,7 +16,8 @@ RSpec.configure do |config|
homesick.stub(:say_status) homesick.stub(:say_status)
end end
def given_castle(name, path=name, subdirs=[]) def given_castle(path, subdirs=[])
name = Pathname.new(path).basename
castles.directory(path) do |castle| castles.directory(path) do |castle|
Dir.chdir(castle) do Dir.chdir(castle) do
system "git init >/dev/null 2>&1" system "git init >/dev/null 2>&1"