Commit 9ccd8e89 authored by Fabio Pelosin's avatar Fabio Pelosin

[ExternalSources] Clen specs.

parent 6e2d4f6b
...@@ -88,7 +88,7 @@ module Pod ...@@ -88,7 +88,7 @@ module Pod
copy_external_source_into_sandbox(sandbox) copy_external_source_into_sandbox(sandbox)
spec = specification_from_local(sandbox) spec = specification_from_local(sandbox)
unless spec unless spec
raise Informative, "No podspec found for `#{name}' in #{description}" raise Informative, "No podspec found for `#{name}` in #{description}"
end end
spec spec
end end
...@@ -167,7 +167,7 @@ module Pod ...@@ -167,7 +167,7 @@ module Pod
# operations are needed. # operations are needed.
# #
def copy_external_source_into_sandbox(sandbox) def copy_external_source_into_sandbox(sandbox)
UI.info("->".green + " Pre-downloading: '#{name}'") do UI.info("->".green + " Pre-downloading: `#{name}`") do
target = sandbox.root + name target = sandbox.root + name
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(sandbox.root + name, @params) downloader = Downloader.for_target(sandbox.root + name, @params)
...@@ -180,7 +180,7 @@ module Pod ...@@ -180,7 +180,7 @@ module Pod
# @see AbstractExternalSource#description # @see AbstractExternalSource#description
# #
def description def description
"from `#{@params[:git]}'".tap do |description| "from `#{@params[:git]}`".tap do |description|
description << ", commit `#{@params[:commit]}`" if @params[:commit] description << ", commit `#{@params[:commit]}`" if @params[:commit]
description << ", branch `#{@params[:branch]}`" if @params[:branch] description << ", branch `#{@params[:branch]}`" if @params[:branch]
description << ", tag `#{@params[:tag]}`" if @params[:tag] description << ", tag `#{@params[:tag]}`" if @params[:tag]
...@@ -208,7 +208,7 @@ module Pod ...@@ -208,7 +208,7 @@ module Pod
# operations are needed. # operations are needed.
# #
def copy_external_source_into_sandbox(sandbox) def copy_external_source_into_sandbox(sandbox)
UI.info("->".green + " Pre-downloading: '#{name}'") do UI.info("->".green + " Pre-downloading: `#{name}`") do
target = sandbox.root + name target = sandbox.root + name
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(sandbox.root + name, @params) downloader = Downloader.for_target(sandbox.root + name, @params)
...@@ -221,10 +221,10 @@ module Pod ...@@ -221,10 +221,10 @@ module Pod
# @see AbstractExternalSource#description # @see AbstractExternalSource#description
# #
def description def description
"from `#{@params[:svn]}'".tap do |description| "from `#{@params[:svn]}`".tap do |description|
description << ", folder `#{@params[:folder]}'" if @params[:folder] description << ", folder `#{@params[:folder]}`" if @params[:folder]
description << ", tag `#{@params[:tag]}'" if @params[:tag] description << ", tag `#{@params[:tag]}`" if @params[:tag]
description << ", revision `#{@params[:revision]}'" if @params[:revision] description << ", revision `#{@params[:revision]}`" if @params[:revision]
end end
end end
end end
...@@ -239,7 +239,7 @@ module Pod ...@@ -239,7 +239,7 @@ module Pod
# @see AbstractExternalSource#copy_external_source_into_sandbox # @see AbstractExternalSource#copy_external_source_into_sandbox
# #
def copy_external_source_into_sandbox(sandbox) def copy_external_source_into_sandbox(sandbox)
UI.info("->".green + " Fetching podspec for `#{name}' from: #{@params[:podspec]}") do UI.info("->".green + " Fetching podspec for `#{name}` from: #{@params[:podspec]}") do
path = @params[:podspec] path = @params[:podspec]
path = Pathname.new(path).expand_path if path.to_s.start_with?("~") path = Pathname.new(path).expand_path if path.to_s.start_with?("~")
require 'open-uri' require 'open-uri'
......
...@@ -25,6 +25,11 @@ module Bacon ...@@ -25,6 +25,11 @@ module Bacon
::Pod::UI.indentation_level = 0 ::Pod::UI.indentation_level = 0
::Pod::UI.title_level = 0 ::Pod::UI.title_level = 0
if SpecHelper.temporary_directory.exist?
SpecHelper.temporary_directory.rmtree
SpecHelper.temporary_directory.mkpath
end
old_run_requirement.bind(self).call(description, spec) old_run_requirement.bind(self).call(description, spec)
end end
end end
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe ExternalSources do describe ExternalSources do
it "returns the instance of appropriate concrete class according to the parameters" do it "returns the instance of appropriate concrete class according to the parameters" do
git = Dependency.new("Reachability", :git => nil) git = Dependency.new("Reachability", :git => nil)
svn = Dependency.new("Reachability", :svn => nil)
podspec = Dependency.new("Reachability", :podspec => nil) podspec = Dependency.new("Reachability", :podspec => nil)
local = Dependency.new("Reachability", :local => nil) local = Dependency.new("Reachability", :local => nil)
ExternalSources.from_dependency(git).class.should == ExternalSources::GitSource ExternalSources.from_dependency(git).class.should == ExternalSources::GitSource
ExternalSources.from_dependency(svn).class.should == ExternalSources::SvnSource
ExternalSources.from_dependency(podspec).class.should == ExternalSources::PodspecSource ExternalSources.from_dependency(podspec).class.should == ExternalSources::PodspecSource
ExternalSources.from_dependency(local).class.should == ExternalSources::LocalSource ExternalSources.from_dependency(local).class.should == ExternalSources::LocalSource
end end
end end
#---------------------------------------------------------------------------#
describe ExternalSources::AbstractExternalSource do describe ExternalSources::AbstractExternalSource do
xit "returns the name" do end
xit "returns the params" do end it "compares to another" do
xit "returns the compares to another" do end dependency_1 = Dependency.new("Reachability", :git => 'url')
xit "returns the specification" do end dependency_2 = Dependency.new("Another_name", :git => 'url')
xit "returns the specification from the sandbox if available" do end dependency_3 = Dependency.new("Reachability", :git => 'another_url')
xit "returns the specification fetching it from the external source" do end
dependency_1.should.be == dependency_1
dependency_1.should.not.be == dependency_2
dependency_1.should.not.be == dependency_3
end
before do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability'))
@external_source = ExternalSources.from_dependency(dependency)
end
it "returns the specification from the sandbox if available" do
@external_source.specification_from_external(config.sandbox)
@external_source.expects(:specification_from_external).never
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
it "returns the specification from the remote if needed" do
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
it "returns the specification from the sandbox if available" do
@external_source.specification_from_external(config.sandbox)
@external_source.specification_from_local(config.sandbox).name.should == 'Reachability'
end
it "returns nil if the specification from the sandbox is not available" do
@external_source.specification_from_local(config.sandbox).should.be.nil
end
it "returns the specification fetching it from the external source in any case" do
@external_source.specification_from_external(config.sandbox).name.should == 'Reachability'
end
end end
#---------------------------------------------------------------------------#
describe ExternalSources::GitSource do describe ExternalSources::GitSource do
it "creates a copy of the podspec" do
before do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability'))
external_source = ExternalSources.from_dependency(dependency) @external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox) end
it "creates a copy of the podspec" do
@external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) @external_source.copy_external_source_into_sandbox(config.sandbox)
external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox)
config.sandbox.predownloaded_pods.should == ["Reachability"] config.sandbox.predownloaded_pods.should == ["Reachability"]
end end
xit "returns the description" do end it "returns the description" do
@external_source.description.should.match %r|from `.*Reachability`|
end
end end
#---------------------------------------------------------------------------#
describe ExternalSources::SvnSource do describe ExternalSources::SvnSource do
it "creates a copy of the podspec" do before do
dependency = Dependency.new("SvnSource", :svn => "file://#{fixture('subversion-repo/trunk')}") dependency = Dependency.new("SvnSource", :svn => "file://#{fixture('subversion-repo/trunk')}")
external_source = ExternalSources.from_dependency(dependency) @external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox) end
it "creates a copy of the podspec" do
@external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/SvnSource.podspec' path = config.sandbox.root + 'Local Podspecs/SvnSource.podspec'
path.should.exist? path.should.exist?
end end
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
dependency = Dependency.new("SvnSource", :svn => "file://#{fixture('subversion-repo/trunk')}") @external_source.copy_external_source_into_sandbox(config.sandbox)
external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox)
config.sandbox.predownloaded_pods.should == ["SvnSource"] config.sandbox.predownloaded_pods.should == ["SvnSource"]
end end
xit "returns the description" do end it "returns the description" do
@external_source.description.should.match %r|from `.*subversion-repo/trunk`|
end
end end
#---------------------------------------------------------------------------#
describe ExternalSources::PodspecSource do describe ExternalSources::PodspecSource do
before do
podspec_path = fixture('integration/Reachability/Reachability.podspec')
dependency = Dependency.new("Reachability", :podspec => podspec_path.to_s)
@external_source = ExternalSources.from_dependency(dependency)
end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
dependency = Dependency.new("Reachability", :podspec => fixture('integration/Reachability/Reachability.podspec').to_s) @external_source.copy_external_source_into_sandbox(config.sandbox)
external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
xit "returns the description" do end it "returns the description" do
@external_source.description.should.match %r|from `.*Reachability/Reachability.podspec`|
end
end end
#---------------------------------------------------------------------------#
describe ExternalSources::LocalSource do describe ExternalSources::LocalSource do
it "creates a copy of the podspec" do
before do
podspec_path = fixture('integration/Reachability/Reachability.podspec')
dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability'))
external_source = ExternalSources.from_dependency(dependency) @external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox) end
it "creates a copy of the podspec" do
@external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
xit "returns the description" do end it "returns the description" do
@external_source.description.should.match %r|from `.*integration/Reachability`|
end
end end
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