Permalink
Browse files

+ downloader spec

  • Loading branch information...
1 parent 0785edf commit deb4712c09c4d0299d7f91b59f325055064e356f @alloy alloy committed Sep 14, 2011
View
@@ -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
@@ -1,6 +1,6 @@
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 @@ def self.for_source(source, pod_root)
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 @@ def download_if_necessary!
# 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
Submodule banana-lib added at f046c1
@@ -0,0 +1,35 @@
+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
+
View
@@ -1,12 +1,13 @@
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 @@
class Bacon::Context
include Pod::Config::Mixin
+
+ include SpecHelper::Fixture
end
Pod::Config.instance.repos_dir = SpecHelper.tmp_repos_path
@@ -4,10 +4,10 @@ def self.fixture(name)
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 @@ def self.temporary_directory
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)
@@ -0,0 +1,14 @@
+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

0 comments on commit deb4712

Please sign in to comment.