Commit deb4712c authored by Eloy Duran's avatar Eloy Duran

+ downloader spec

parent 0785edfb
...@@ -11,7 +11,10 @@ module Pod ...@@ -11,7 +11,10 @@ module Pod
autoload :Version, 'cocoa_pods/version' autoload :Version, 'cocoa_pods/version'
module Xcode module Xcode
autoload :Config, 'cocoa_pods/xcode/config' autoload :Config, 'cocoa_pods/xcode/config'
autoload :Project, 'cocoa_pods/xcode/project' autoload :Project, 'cocoa_pods/xcode/project'
end end
autoload :Pathname, 'pathname'
autoload :Executioner, 'executioner'
end end
module Pod module Pod
class Downloader class Downloader
def self.for_source(source, pod_root) def self.for_source(pod_root, source)
options = source.dup options = source.dup
if url = options.delete(:git) if url = options.delete(:git)
Git.new(pod_root, url, options) Git.new(pod_root, url, options)
...@@ -9,12 +9,13 @@ module Pod ...@@ -9,12 +9,13 @@ module Pod
end end
end end
attr_reader :pod_root, :url, :options
def initialize(pod_root, url, options) def initialize(pod_root, url, options)
@pod_root, @url, @options = pod_root, url, options @pod_root, @url, @options = pod_root, url, options
end end
class Git < Downloader class Git < Downloader
require 'rubygems'
require 'executioner' require 'executioner'
include Executioner include Executioner
# TODO make Executioner: # TODO make Executioner:
......
...@@ -178,7 +178,7 @@ module Pod ...@@ -178,7 +178,7 @@ module Pod
# end # end
# end # end
def download! def download!
downloader = Downloader.for_source(@source, pod_destroot) downloader = Downloader.for_source(pod_destroot, @source)
downloader.download downloader.download
downloader.clean if config.clean downloader.clean if config.clean
end 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 'rubygems'
require 'mac_bacon' 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' require 'cocoa_pods'
$:.unshift File.join(ROOT, 'spec') $:.unshift((ROOT + 'spec').to_s)
require 'spec_helper/fixture' require 'spec_helper/fixture'
require 'spec_helper/git' require 'spec_helper/git'
require 'spec_helper/log' require 'spec_helper/log'
...@@ -17,6 +18,8 @@ require 'spec_helper/temporary_directory' ...@@ -17,6 +18,8 @@ require 'spec_helper/temporary_directory'
class Bacon::Context class Bacon::Context
include Pod::Config::Mixin include Pod::Config::Mixin
include SpecHelper::Fixture
end end
Pod::Config.instance.repos_dir = SpecHelper.tmp_repos_path Pod::Config.instance.repos_dir = SpecHelper.tmp_repos_path
...@@ -4,10 +4,10 @@ module SpecHelper ...@@ -4,10 +4,10 @@ module SpecHelper
end end
module Fixture module Fixture
ROOT = File.join(::ROOT, 'spec', 'fixtures') ROOT = ::ROOT + 'spec/fixtures'
def fixture(name) def fixture(name)
File.join(ROOT, name) ROOT + name
end end
module_function :fixture module_function :fixture
end end
......
...@@ -7,16 +7,16 @@ module SpecHelper ...@@ -7,16 +7,16 @@ module SpecHelper
module TemporaryDirectory module TemporaryDirectory
def temporary_directory def temporary_directory
File.join(ROOT, 'tmp') ROOT + 'tmp'
end end
module_function :temporary_directory module_function :temporary_directory
def setup_temporary_directory def setup_temporary_directory
FileUtils.mkdir_p(temporary_directory) temporary_directory.mkpath
end end
def teardown_temporary_directory def teardown_temporary_directory
FileUtils.rm_rf(temporary_directory) temporary_directory.rmtree
end end
def self.extended(base) 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