Commit 7ce508b5 authored by Eloy Duran's avatar Eloy Duran

Implement the setup command.

parent c9e64e33
*.swp
*.swo
.DS_Store
tmp
module Pod
module Command
class Command
autoload :Help, 'cocoa_pods/command/help'
autoload :Setup, 'cocoa_pods/command/setup'
autoload :Spec, 'cocoa_pods/command/spec'
......@@ -15,5 +15,12 @@ module Pod
end
command.new(*argv)
end
def initialize(*argv)
raise "unknown argument(s): #{argv.join(', ')}" unless argv.empty?
end
def run
end
end
end
module Pod
module Command
class Help
class Command
class Help < Command
end
end
end
module Pod
module Command
class Repo
class Command
class Repo < Command
end
end
end
......
require 'fileutils'
require 'executioner'
module Pod
module Command
class Setup
class Command
class Setup < Command
include Executioner
executable :git
def repos_dir
File.expand_path('~/.cocoa-pods')
end
def master_repo_dir
File.join(repos_dir, 'master')
end
def master_repo_url
'git://github.com/alloy/cocoa-pod-specs.git'
end
def run
FileUtils.mkdir_p(repos_dir)
Dir.chdir(repos_dir) { git("clone #{master_repo_url} master") }
end
end
end
end
module Pod
module Command
class Spec
class Command
class Spec < Command
end
end
end
Subproject commit c807c4a9bff2af0ada17863065eb44bda0275a7d
require File.expand_path('../../spec_helper', __FILE__)
require 'executioner'
describe "Pod::Command" do
extend SpecHelper::Fixture
extend SpecHelper::Git
extend SpecHelper::Log
extend SpecHelper::TemporaryDirectory
it "creates the local spec-repos directory and creates a clone of the `master' repo" do
#log!
command = Pod::Command.parse("setup")
def command.repos_dir; SpecHelper.tmp_repos_path; end
def command.master_repo_url; SpecHelper.fixture('master-spec-repo.git'); end
command.run
File.should.exist command.master_repo_dir
git_config('remote.origin.url').should == command.master_repo_url
end
end
require 'rubygems'
require 'mac_bacon'
$:.unshift File.expand_path('../../lib', __FILE__)
ROOT = File.expand_path('../../', __FILE__)
$:.unshift File.join(ROOT, 'lib')
require 'cocoa_pods'
$:.unshift File.join(ROOT, 'spec')
require 'spec_helper/fixture'
require 'spec_helper/git'
require 'spec_helper/log'
require 'spec_helper/temporary_directory'
#TMP_DIR = SpecHelper::TemporaryDirectory.temporary_directory
#TMP_COCOA_PODS_DIR = File.join(TMP_DIR, 'cocoa-pods')
module SpecHelper
def self.fixture(name)
Fixture.fixture(name)
end
module Fixture
ROOT = File.join(::ROOT, 'spec', 'fixtures')
def fixture(name)
File.join(ROOT, name)
end
module_function :fixture
end
end
require 'spec_helper/temporary_directory'
require 'executioner'
module SpecHelper
def self.tmp_repos_path
Git.tmp_repos_path
end
module Git
def tmp_repos_path
File.join(SpecHelper.temporary_directory, 'cocoa-pods')
end
module_function :tmp_repos_path
def tmp_master_repo_path
File.join(tmp_repos_path, 'master')
end
include Executioner
executable :git
alias_method :git_super, :git
def git(command)
Dir.chdir(tmp_master_repo_path) { git_super(command).strip }
end
def git_config(attr)
git "config --get #{attr}"
end
end
end
module SpecHelper
module Log
def log!
puts
logger = Object.new
def logger.debug(msg); puts msg; end
Executioner.logger = logger
end
def self.extended(context)
context.after do
Executioner.logger = nil
end
end
end
end
require 'fileutils'
module SpecHelper
def self.temporary_directory
TemporaryDirectory.temporary_directory
end
module TemporaryDirectory
def temporary_directory
File.join(ROOT, 'tmp')
end
module_function :temporary_directory
def setup_temporary_directory
FileUtils.mkdir_p(temporary_directory)
end
def teardown_temporary_directory
FileUtils.rm_rf(temporary_directory)
end
def self.extended(base)
base.before do
teardown_temporary_directory
setup_temporary_directory
end
end
end
end
......@@ -8,3 +8,25 @@ describe "Pod::Command" do
Pod::Command.parse("repo").should.be.instance_of Pod::Command::Repo
end
end
describe "Pod::Command::Setup" do
it "complains about unknown arguments" do
lambda { Pod::Command::Setup.new('something') }.should.raise
end
before do
@command = Pod::Command::Setup.new
end
it "returns the URL of the `master' spec-repo" do
@command.master_repo_url.should == 'git://github.com/alloy/cocoa-pod-specs.git'
end
it "returns the path of the directory where the local spec-repos will be stored" do
@command.repos_dir.should == File.expand_path("~/.cocoa-pods")
end
it "returns the path of the directory where the `master' spec-repo will be" do
@command.master_repo_dir.should == File.expand_path("~/.cocoa-pods/master")
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment