Commit deb4712c authored by Eloy Duran's avatar Eloy Duran

+ downloader spec

parent 0785edfb
......@@ -11,7 +11,10 @@ module Pod
autoload :Version, 'cocoa_pods/version'
module Xcode
autoload :Config, 'cocoa_pods/xcode/config'
autoload :Project, 'cocoa_pods/xcode/project'
autoload :Config, 'cocoa_pods/xcode/config'
autoload :Project, 'cocoa_pods/xcode/project'
end
autoload :Pathname, 'pathname'
autoload :Executioner, 'executioner'
end
module Pod
class Downloader
def self.for_source(source, pod_root)
def self.for_source(pod_root, source)
options = source.dup
if url = options.delete(:git)
Git.new(pod_root, url, options)
......@@ -9,12 +9,13 @@ module Pod
end
end
attr_reader :pod_root, :url, :options
def initialize(pod_root, url, options)
@pod_root, @url, @options = pod_root, url, options
end
class Git < Downloader
require 'rubygems'
require 'executioner'
include Executioner
# TODO make Executioner:
......
......@@ -178,7 +178,7 @@ module Pod
# end
# end
def download!
downloader = Downloader.for_source(@source, pod_destroot)
downloader = Downloader.for_source(pod_destroot, @source)
downloader.download
downloader.clean if config.clean
end
......
banana-lib @ f046c1a0
Subproject commit f046c1a0fc673a01cf1ce4607c5d1857ce08b44a
require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Downloader" do
extend SpecHelper::TemporaryDirectory
before do
@dir = temporary_directory + 'banana-lib'
end
it "check's out a specific commit" do
downloader = Pod::Downloader.for_source(@dir,
:git => fixture('banana-lib'), :commit => '02467b074d4dc9f6a75b8cd3ab80d9bf37887b01'
)
downloader.download
(@dir + 'README').read.strip.should == 'first commit'
end
it "check's out a specific tag" do
downloader = Pod::Downloader.for_source(@dir,
:git => fixture('banana-lib'), :tag => 'v1.0'
)
downloader.download
(@dir + 'README').read.strip.should == 'v1.0'
end
it "removes the .git directory" do
downloader = Pod::Downloader.for_source(@dir,
:git => fixture('banana-lib'), :tag => 'v1.0'
)
downloader.download
downloader.clean
(@dir + '.git').should.not.exist
end
end
require 'rubygems'
require 'mac_bacon'
ROOT = File.expand_path('../../', __FILE__)
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$:.unshift File.join(ROOT, 'lib')
$:.unshift((ROOT + 'lib').to_s)
require 'cocoa_pods'
$:.unshift File.join(ROOT, 'spec')
$:.unshift((ROOT + 'spec').to_s)
require 'spec_helper/fixture'
require 'spec_helper/git'
require 'spec_helper/log'
......@@ -17,6 +18,8 @@ require 'spec_helper/temporary_directory'
class Bacon::Context
include Pod::Config::Mixin
include SpecHelper::Fixture
end
Pod::Config.instance.repos_dir = SpecHelper.tmp_repos_path
......@@ -4,10 +4,10 @@ module SpecHelper
end
module Fixture
ROOT = File.join(::ROOT, 'spec', 'fixtures')
ROOT = ::ROOT + 'spec/fixtures'
def fixture(name)
File.join(ROOT, name)
ROOT + name
end
module_function :fixture
end
......
......@@ -7,16 +7,16 @@ module SpecHelper
module TemporaryDirectory
def temporary_directory
File.join(ROOT, 'tmp')
ROOT + 'tmp'
end
module_function :temporary_directory
def setup_temporary_directory
FileUtils.mkdir_p(temporary_directory)
temporary_directory.mkpath
end
def teardown_temporary_directory
FileUtils.rm_rf(temporary_directory)
temporary_directory.rmtree
end
def self.extended(base)
......
require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Downloader" do
it "returns a git downloader" do
downloader = Pod::Downloader.for_source(
'/path/to/pod_root',
:git => 'http://example.local/banana.git', :tag => 'v1.0',
)
downloader.should.be.instance_of Pod::Downloader::Git
downloader.pod_root.should == '/path/to/pod_root'
downloader.url.should == 'http://example.local/banana.git'
downloader.options.should == { :tag => 'v1.0' }
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