Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ downloader spec

  • Loading branch information...
commit deb4712c09c4d0299d7f91b59f325055064e356f 1 parent 0785edf
@alloy alloy authored
View
7 lib/cocoa_pods.rb
@@ -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
View
5 lib/cocoa_pods/downloader.rb
@@ -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:
View
2  lib/cocoa_pods/specification.rb
@@ -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
1  spec/fixtures/banana-lib
@@ -0,0 +1 @@
+Subproject commit f046c1a0fc673a01cf1ce4607c5d1857ce08b44a
View
35 spec/functional/downloader_spec.rb
@@ -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
9 spec/spec_helper.rb
@@ -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
View
4 spec/spec_helper/fixture.rb
@@ -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
View
6 spec/spec_helper/temporary_directory.rb
@@ -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)
View
14 spec/unit/downloader_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.