Extract common setup into spec_helper, add given_castle helper.
This commit is contained in:
@@ -5,15 +5,28 @@ require 'rspec'
|
||||
require 'rspec/autorun'
|
||||
require 'construct'
|
||||
|
||||
Rspec.configure do |config|
|
||||
RSpec.configure do |config|
|
||||
config.include Construct::Helpers
|
||||
|
||||
config.before do
|
||||
@user_dir = create_construct
|
||||
ENV['HOME'] = @user_dir.to_s
|
||||
|
||||
@repos_dir = @user_dir.directory(".homesick/repos")
|
||||
homesick.stub!(:repos_dir).and_return(@repos_dir)
|
||||
end
|
||||
|
||||
config.after do
|
||||
@user_dir.destroy!
|
||||
end
|
||||
|
||||
def given_castle(name, path=name)
|
||||
@repos_dir.directory(path) do |castle|
|
||||
Dir.chdir(castle) do
|
||||
system "git init >/dev/null 2>&1"
|
||||
system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1"
|
||||
return castle.directory("home")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user