Commit 1174213a authored by clarkda's avatar clarkda

merging upstream and resolving conflicts

parents 788cb118 f28d2d4d
...@@ -26,6 +26,28 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -26,6 +26,28 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Core#97](https://github.com/CocoaPods/Core/pull/97) [Core#97](https://github.com/CocoaPods/Core/pull/97)
[Core#98](https://github.com/CocoaPods/Core/issues/98) [Core#98](https://github.com/CocoaPods/Core/issues/98)
* Validate the reachability of screenshot URLs in podspecs while linting a
specification.
[Kyle Fuller](https://github.com/kylef)
[#2010](https://github.com/CocoaPods/CocoaPods/issues/2010)
* Prevent the user from using `pod` commands as root
[Kyle Fuller](https://github.com/kylef)
[#1815](https://github.com/CocoaPods/CocoaPods/issues/1815)
* Fix to keep absolute paths specified for local pods as is.
[Samuel Ford](https://github.com/samuelwford)
[#1042](https://github.com/CocoaPods/CocoaPods/issues/1042)
* `pod update` prints the previous version of the updated pods.
[Andrea Mazzini](https://github.com/andreamazz)
[#2008](https://github.com/CocoaPods/CocoaPods/issues/2008)
##### Bug Fixes
* Support HTTP redirects when linting homepage and screenshots.
[Boris Bügling](https://github.com/neonichu)
[#2027](https://github.com/CocoaPods/CocoaPods/pull/2027)
## 0.31.1 ## 0.31.1
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0)
...@@ -62,6 +84,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -62,6 +84,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Robert Zuber](https://github.com/z00b) [Robert Zuber](https://github.com/z00b)
[#1617](https://github.com/CocoaPods/CocoaPods/issues/1617) [#1617](https://github.com/CocoaPods/CocoaPods/issues/1617)
* Generated prefix header file will now have unique prefix_header_contents for
Pods with subspecs.
[Luis de la Rosa](https://github.com/luisdelarosa)
[#1449](https://github.com/CocoaPods/CocoaPods/issues/1449)
* The linter will now check the reachability of the homepage of Podspecs during * The linter will now check the reachability of the homepage of Podspecs during
a full lint. a full lint.
[Richard Lee](https://github.com/dlackty) [Richard Lee](https://github.com/dlackty)
......
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 5736f3cfbebe805c04e67a53729b9fa098ea8f9d revision: f8a920b02c19273f689c1f930af580d473c7852f
branch: master branch: master
specs: specs:
cocoapods-core (0.31.1) cocoapods-core (0.31.1)
...@@ -18,7 +18,7 @@ GIT ...@@ -18,7 +18,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 357d061b0b3a60fa6ac0a40cb3da6ce7689e3c9e revision: 1ead6368b83d492ebf3194e45fb0d732632446c4
branch: master branch: master
specs: specs:
xcodeproj (0.16.0) xcodeproj (0.16.0)
...@@ -59,10 +59,10 @@ GIT ...@@ -59,10 +59,10 @@ GIT
GIT GIT
remote: https://github.com/irrationalfab/PrettyBacon.git remote: https://github.com/irrationalfab/PrettyBacon.git
revision: eaf7e6c786fd5ccc6fb88e943bf7c5e6c27569a3 revision: 1eeb06f7d381acd65414b86b42fdf3538faae01c
branch: master branch: master
specs: specs:
prettybacon (0.0.1) prettybacon (0.0.2)
bacon (~> 1.2) bacon (~> 1.2)
GIT GIT
...@@ -148,7 +148,7 @@ GEM ...@@ -148,7 +148,7 @@ GEM
redcarpet (2.3.0) redcarpet (2.3.0)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
safe_yaml (1.0.1) safe_yaml (1.0.2)
simplecov (0.8.2) simplecov (0.8.2)
docile (~> 1.1.0) docile (~> 1.1.0)
multi_json multi_json
...@@ -158,7 +158,7 @@ GEM ...@@ -158,7 +158,7 @@ GEM
term-ansicolor (1.3.0) term-ansicolor (1.3.0)
tins (~> 1.0) tins (~> 1.0)
thor (0.19.1) thor (0.19.1)
tins (1.0.1) tins (1.1.0)
webmock (1.15.2) webmock (1.15.2)
addressable (>= 2.2.7) addressable (>= 2.2.7)
crack (>= 0.3.2) crack (>= 0.3.2)
......
...@@ -129,6 +129,7 @@ namespace :spec do ...@@ -129,6 +129,7 @@ namespace :spec do
# #
task :all => :unpack_fixture_tarballs do task :all => :unpack_fixture_tarballs do
ENV['GENERATE_COVERAGE'] = 'true' ENV['GENERATE_COVERAGE'] = 'true'
puts "\033[0;32mUsing #{`ruby --version`}\033[0m"
title 'Running the specs' title 'Running the specs'
sh "bundle exec bacon #{specs('**/*')}" sh "bundle exec bacon #{specs('**/*')}"
...@@ -188,7 +189,8 @@ namespace :spec do ...@@ -188,7 +189,8 @@ namespace :spec do
desc "Rebuilds integration fixtures" desc "Rebuilds integration fixtures"
task :rebuild_integration_fixtures do task :rebuild_integration_fixtures do
title 'Running Integration tests' title 'Running Integration tests'
`bundle exec bacon spec/integration.rb` sh 'rm -rf spec/cocoapods-integration-specs/tmp'
Rake::Task['spec:integration'].invoke
title 'Storing fixtures' title 'Storing fixtures'
# Copy the files to the files produced by the specs to the after folders # Copy the files to the files produced by the specs to the after folders
......
...@@ -72,24 +72,3 @@ if ENV['COCOA_PODS_ENV'] == 'development' ...@@ -72,24 +72,3 @@ if ENV['COCOA_PODS_ENV'] == 'development'
# require 'awesome_print' # require 'awesome_print'
# require 'pry' # require 'pry'
end end
# TODO remove for CocoaPods 0.31
#
module Pod
class Specification
def pre_install(&block)
UI.warn "[#{self}] The pre install hook of the specification " \
"DSL has been deprecated, use the `resource_bundles` or the " \
"`prepare_command` attributes."
UI.puts "[#{self}] The pre_install hook will be removed in the next release".red
@pre_install_callback = block
end
def post_install(&block)
UI.warn "[#{self}] The post install hook of the specification " \
"DSL has been deprecated, use the `resource_bundles` or the " \
"`prepare_command` attributes."
UI.puts "[#{self}] The post_install hook will be removed in the next release".red
@post_install_callback = block
end
end
end
...@@ -43,11 +43,14 @@ module Pod ...@@ -43,11 +43,14 @@ module Pod
end end
def self.run(argv) def self.run(argv)
help! "You cannot run CocoaPods as root." if Process.uid == 0
argv = CLAide::ARGV.new(argv) argv = CLAide::ARGV.new(argv)
if argv.flag?('version') if argv.flag?('version')
UI.puts VERSION UI.puts VERSION
exit 0 exit 0
end end
super(argv) super(argv)
UI.print_warnings UI.print_warnings
end end
......
...@@ -480,7 +480,7 @@ Pod::Spec.new do |s| ...@@ -480,7 +480,7 @@ Pod::Spec.new do |s|
DESC DESC
s.homepage = "#{data[:homepage]}" s.homepage = "#{data[:homepage]}"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
......
...@@ -352,7 +352,8 @@ module Pod ...@@ -352,7 +352,8 @@ module Pod
UI.titled_section("Fetching podspec for `#{name}` #{description}", { :verbose_prefix => "-> " }) do UI.titled_section("Fetching podspec for `#{name}` #{description}", { :verbose_prefix => "-> " }) do
podspec = podspec_path podspec = podspec_path
store_podspec(sandbox, podspec) store_podspec(sandbox, podspec)
sandbox.store_local_path(name, podspec.dirname) path_is_absolute_or_rooted_to_home = declared_path.absolute? || declared_path.to_s.start_with?('~')
sandbox.store_local_path(name, podspec.dirname, path_is_absolute_or_rooted_to_home)
end end
end end
...@@ -368,10 +369,15 @@ module Pod ...@@ -368,10 +369,15 @@ module Pod
# @!group Helpers # @!group Helpers
# @return [Pathname] the path as declared in the podspec
#
def declared_path
Pathname.new params[:path] || params[:local]
end
# @return [Pathname] the path of the podspec. # @return [Pathname] the path of the podspec.
# #
def podspec_path def podspec_path
declared_path = (params[:path] || params[:local]).to_s
path_with_ext = File.extname(declared_path) == '.podspec' ? declared_path : "#{declared_path}/#{name}.podspec" path_with_ext = File.extname(declared_path) == '.podspec' ? declared_path : "#{declared_path}/#{name}.podspec"
podfile_dir = File.dirname(podfile_path || '') podfile_dir = File.dirname(podfile_path || '')
absolute_path = File.expand_path(path_with_ext, podfile_dir) absolute_path = File.expand_path(path_with_ext, podfile_dir)
......
...@@ -40,9 +40,12 @@ module Pod ...@@ -40,9 +40,12 @@ module Pod
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h` # added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported. # is imported.
# #
# @note Only unique prefix_header_contents are added to the prefix header.
#
# @return [String] # @return [String]
# #
# @todo Subspecs can specify prefix header information too. # @todo Subspecs can specify prefix header information too.
# @todo Check to see if we have a similar duplication issue with file_accessor.prefix_header.
# #
def generate def generate
result = "#ifdef __OBJC__\n" result = "#ifdef __OBJC__\n"
...@@ -53,12 +56,18 @@ module Pod ...@@ -53,12 +56,18 @@ module Pod
result << %|\n#import "#{import}"| result << %|\n#import "#{import}"|
end end
file_accessors.each do |file_accessor| unique_prefix_header_contents = file_accessors.collect do |file_accessor|
file_accessor.spec_consumer.prefix_header_contents
end.compact.uniq
result << "\n"
unique_prefix_header_contents.each do |prefix_header_contents|
result << prefix_header_contents
result << "\n" result << "\n"
if prefix_header_contents = file_accessor.spec_consumer.prefix_header_contents end
result << prefix_header_contents
result << "\n" file_accessors.each do |file_accessor|
end
if prefix_header = file_accessor.prefix_header if prefix_header = file_accessor.prefix_header
result << Pathname(prefix_header).read result << Pathname(prefix_header).read
end end
......
...@@ -236,7 +236,13 @@ module Pod ...@@ -236,7 +236,13 @@ module Pod
title_options = { :verbose_prefix => "-> ".green } title_options = { :verbose_prefix => "-> ".green }
root_specs.sort_by(&:name).each do |spec| root_specs.sort_by(&:name).each do |spec|
if pods_to_install.include?(spec.name) if pods_to_install.include?(spec.name)
UI.titled_section("Installing #{spec}".green, title_options) do if sandbox_state.changed.include?(spec.name) && sandbox.manifest
previous = sandbox.manifest.version(spec.name)
title = "Installing #{spec.name} #{spec.version} (was #{previous})"
else
title = "Installing #{spec}"
end
UI.titled_section(title.green, title_options) do
install_source_of_pod(spec.name) install_source_of_pod(spec.name)
end end
else else
...@@ -296,9 +302,10 @@ module Pod ...@@ -296,9 +302,10 @@ module Pod
pod_names = pod_targets.map(&:pod_name).uniq pod_names = pod_targets.map(&:pod_name).uniq
pod_names.each do |pod_name| pod_names.each do |pod_name|
path = sandbox.pod_dir(pod_name)
local = sandbox.local?(pod_name) local = sandbox.local?(pod_name)
@pods_project.add_pod_group(pod_name, path, local) path = sandbox.pod_dir(pod_name)
was_absolute = sandbox.local_path_was_absolute?(pod_name)
@pods_project.add_pod_group(pod_name, path, local, was_absolute)
end end
if config.podfile_path if config.podfile_path
......
...@@ -69,6 +69,7 @@ module Pod ...@@ -69,6 +69,7 @@ module Pod
@head_pods = [] @head_pods = []
@checkout_sources = {} @checkout_sources = {}
@development_pods = {} @development_pods = {}
@pods_with_absolute_path = []
end end
# @return [Lockfile] the manifest which contains the information about the # @return [Lockfile] the manifest which contains the information about the
...@@ -158,7 +159,17 @@ module Pod ...@@ -158,7 +159,17 @@ module Pod
root + root_name root + root_name
end end
end end
# Returns true if the path as originally specified was absolute.
#
# @param [String] name
#
# @return [Bool] true if originally absolute
#
def local_path_was_absolute?(name)
@pods_with_absolute_path.include? name
end
# @return [Pathname] the directory where to store the documentation. # @return [Pathname] the directory where to store the documentation.
# #
def documentation_dir def documentation_dir
...@@ -338,11 +349,15 @@ module Pod ...@@ -338,11 +349,15 @@ module Pod
# @param [#to_s] path # @param [#to_s] path
# The local path where the Pod is stored. # The local path where the Pod is stored.
# #
# @param [Bool] was_absolute
# True if the specified local path was absolute.
#
# @return [void] # @return [void]
# #
def store_local_path(name, path) def store_local_path(name, path, was_absolute = false)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
development_pods[root_name] = path.to_s development_pods[root_name] = path.to_s
@pods_with_absolute_path << root_name if was_absolute
end end
# @return [Hash{String=>String}] The path of the Pods with a local source # @return [Hash{String=>String}] The path of the Pods with a local source
......
...@@ -197,6 +197,7 @@ module Pod ...@@ -197,6 +197,7 @@ module Pod
# #
def perform_extensive_analysis(spec) def perform_extensive_analysis(spec)
validate_homepage(spec) validate_homepage(spec)
validate_screenshots(spec)
spec.available_platforms.each do |platform| spec.available_platforms.each do |platform|
UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
...@@ -222,22 +223,60 @@ module Pod ...@@ -222,22 +223,60 @@ module Pod
attr_accessor :consumer attr_accessor :consumer
attr_accessor :subspec_name attr_accessor :subspec_name
# Performs validations related to the `homepage` attribute. MAX_HTTP_REDIRECTS = 3
# Performs validation of a URL
# #
def validate_homepage(spec) def validate_url(url)
require 'rest' require 'rest'
homepage = spec.homepage
return unless homepage
begin begin
resp = ::REST.head(homepage) redirects = 0
resp = nil
loop do
resp = ::REST.head(url)
if resp.status_code >= 400
resp = ::REST.get(url)
end
if [301, 302, 303, 307, 308].include? resp.status_code
url = resp.headers['location'].first
redirects += 1
else
break
end
break unless redirects < MAX_HTTP_REDIRECTS
end
rescue rescue
warning "There was a problem validating the homepage." warning "There was a problem validating the URL #{url}."
resp = nil resp = nil
end end
if resp && !resp.success? if resp && !resp.success?
warning "The homepage is not reachable." warning "The URL (#{url}) is not reachable."
end
resp
end
# Performs validations related to the `homepage` attribute.
#
def validate_homepage(spec)
if spec.homepage
validate_url(spec.homepage)
end
end
# Performs validation related to the `screenshots` attribute.
#
def validate_screenshots(spec)
spec.screenshots.compact.each do |screenshot|
request = validate_url(screenshot)
if request && !(request.headers['content-type'] && request.headers['content-type'].first =~ /image\/.*/i)
warning "The screenshot #{screenshot} is not a valid image."
end
end end
end end
......
Subproject commit d0378da111a5368a28c019e57e4a9f3d3d8e9d94 Subproject commit 367aaee9111972a40d0569155f40cf6bb63e4634
...@@ -14,5 +14,9 @@ module Pod ...@@ -14,5 +14,9 @@ module Pod
UI.output.should.include 'spec/fixtures/spec-repos/master/AFNetworking' UI.output.should.include 'spec/fixtures/spec-repos/master/AFNetworking'
end end
it "doesn't let you run as root" do
Process.stubs(:uid).returns(0)
lambda { Pod::Command.run(['--version']) }.should.raise CLAide::Help
end
end end
end end
...@@ -331,6 +331,10 @@ describe "Integration" do ...@@ -331,6 +331,10 @@ describe "Integration" do
check "install --no-repo-update", "install_subspecs" check "install --no-repo-update", "install_subspecs"
end end
describe "Installs a Pod with subspecs and does not duplicate the prefix header" do
check "install --no-repo-update", "install_subspecs_no_duplicate_prefix"
end
describe "Installs a Pod with a local source" do describe "Installs a Pod with a local source" do
check "install --no-repo-update", "install_local_source" check "install --no-repo-update", "install_local_source"
end end
......
...@@ -21,6 +21,43 @@ module Pod ...@@ -21,6 +21,43 @@ module Pod
EOS EOS
end end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared" do
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil
@spec.subspec 'UI' do |subspec|
subspec.source_files = 'Source/UI/*.{h,m}'
end
@gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared multiple times" do
@spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil
@spec.subspec 'UI' do |su|
su.source_files = 'Source/UI/*.{h,m}'
end
@spec.subspec 'Helpers' do |sh|
sh.source_files = 'Source/Helpers/*.{h,m}'
end
@gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
it "includes the contents of the specification's prefix header file" do it "includes the contents of the specification's prefix header file" do
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__ #ifdef __OBJC__
......
...@@ -21,6 +21,16 @@ def generate_podfile(pods = ['JSONKit']) ...@@ -21,6 +21,16 @@ def generate_podfile(pods = ['JSONKit'])
end end
end end
# @return [Podfile]
#
def generate_local_podfile
podfile = Pod::Podfile.new do
platform :ios
xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
pod 'SSToolkit', :path => SpecHelper.fixture('integration/sstoolkit')
end
end
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
module Pod module Pod
...@@ -194,6 +204,22 @@ module Pod ...@@ -194,6 +204,22 @@ module Pod
@installer.installed_specs.should == [spec] @installer.installed_specs.should == [spec]
end end
it "prints the previous version of a pod while updating the spec" do
spec = Spec.new
spec.name = 'RestKit'
spec.version = '2.0'
manifest = Lockfile.new({})
manifest.stubs(:version).with('RestKit').returns('1.0')
@installer.sandbox.stubs(:manifest).returns(manifest)
@installer.stubs(:root_specs).returns([spec])
sandbox_state = Installer::Analyzer::SpecsState.new
sandbox_state.changed << 'RestKit'
@installer.stubs(:sandbox_state).returns(sandbox_state)
@installer.expects(:install_source_of_pod).with('RestKit')
@installer.send(:install_pod_sources)
UI.output.should.include 'was 1.0'
end
#--------------------------------------# #--------------------------------------#
describe "#clean" do describe "#clean" do
...@@ -247,6 +273,15 @@ module Pod ...@@ -247,6 +273,15 @@ module Pod
@installer.pods_project.class.should == Pod::Project @installer.pods_project.class.should == Pod::Project
end end
it "preserves Pod paths specified as absolute or rooted to home" do
local_podfile = generate_local_podfile
local_installer = Installer.new(config.sandbox, local_podfile)
local_installer.send(:analyze)
local_installer.send(:prepare_pods_project)
group = local_installer.pods_project.group_for_spec('SSToolkit')
Pathname.new(group.path).should.be.absolute
end
it "adds the Podfile to the Pods project" do it "adds the Podfile to the Pods project" do
config.stubs(:podfile_path).returns(Pathname.new('/Podfile')) config.stubs(:podfile_path).returns(Pathname.new('/Podfile'))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
......
...@@ -75,6 +75,7 @@ module Pod ...@@ -75,6 +75,7 @@ module Pod
validator = Validator.new(file) validator = Validator.new(file)
validator.quick = true validator.quick = true
validator.stubs(:validate_homepage) validator.stubs(:validate_homepage)
validator.stubs(:validate_screenshots)
validator.validate validator.validate
validator.validation_dir.should.be == Pathname.new("/private/tmp/CocoaPods/Lint") validator.validation_dir.should.be == Pathname.new("/private/tmp/CocoaPods/Lint")
end end
...@@ -97,16 +98,79 @@ module Pod ...@@ -97,16 +98,79 @@ module Pod
it "checks if the homepage is valid" do it "checks if the homepage is valid" do
WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404) WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404)
WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/not-found/') Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/not-found/')
@sut.validate @sut.validate
@sut.results.map(&:to_s).first.should.match /The homepage is not reachable/ @sut.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
end end
it "indicates if it was not able to validate the homepage" do it "indicates if it was not able to validate the homepage" do
WebMock::API.stub_request(:head, 'banana-corp.local').to_raise(SocketError) WebMock::API.stub_request(:head, 'banana-corp.local').to_raise(SocketError)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/') Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/')
@sut.validate @sut.validate
@sut.results.map(&:to_s).first.should.match /There was a problem validating the homepage/ @sut.results.map(&:to_s).first.should.match /There was a problem validating the URL/
end
it "does not fail if the homepage redirects" do
WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 301, :headers => { 'Location' => 'http://banana-corp.local/found/' } )
WebMock::API.stub_request(:head, /found/).to_return( :status => 200 )
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/redirect/')
@sut.validate
@sut.results.length.should.equal 0
end
it "does not fail if the homepage does not support HEAD" do
WebMock::API.stub_request(:head, /page/).to_return( :status => 405 )
WebMock::API.stub_request(:get, /page/).to_return( :status => 200 )
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate
@sut.results.length.should.equal 0
end
it "does not fail if the homepage errors on HEAD" do
WebMock::API.stub_request(:head, /page/).to_return( :status => 500 )
WebMock::API.stub_request(:get, /page/).to_return( :status => 200 )
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate
@sut.results.length.should.equal 0
end
it "does not follow redirects infinitely" do
WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 301,
:headers => { 'Location' => 'http://banana-corp.local/redirect/' } )
Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect/')
@sut.validate
@sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
end
end
describe "Screenshot validation" do
require 'webmock'
before do
@sut = Validator.new(podspec_path)
@sut.stubs(:install_pod)
@sut.stubs(:build_pod)
@sut.stubs(:check_file_patterns)
@sut.stubs(:tear_down_validation_environment)
@sut.stubs(:validate_homepage)
WebMock::API.stub_request(:head, 'banana-corp.local/valid-image.png').to_return(:status => 200, :headers => { 'Content-Type' => 'image/png' })
end
it "checks if the screenshots are valid" do
Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png'])
@sut.validate
@sut.results.should.be.empty?
end
it "should fail if any of the screenshots URLS do not return an image" do
WebMock::API.stub_request(:head, 'banana-corp.local/').to_return(:status => 200)
Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png', 'http://banana-corp.local/'])
@sut.validate
@sut.results.map(&:to_s).first.should.match /The screenshot .* is not a valid image/
end end
end end
...@@ -114,6 +178,7 @@ module Pod ...@@ -114,6 +178,7 @@ module Pod
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
sut.no_clean = true sut.no_clean = true
sut.validate sut.validate
sut.validation_dir.should.exist sut.validation_dir.should.exist
...@@ -123,6 +188,7 @@ module Pod ...@@ -123,6 +188,7 @@ module Pod
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
sut.expects(:install_pod).twice sut.expects(:install_pod).twice
sut.expects(:build_pod).twice sut.expects(:build_pod).twice
sut.expects(:check_file_patterns).twice sut.expects(:check_file_patterns).twice
...@@ -132,6 +198,7 @@ module Pod ...@@ -132,6 +198,7 @@ module Pod
it "uses the deployment target of the specification" do it "uses the deployment target of the specification" do
sut = Validator.new(podspec_path) sut = Validator.new(podspec_path)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
podfile = sut.send(:podfile_from_spec, :ios, '5.0') podfile = sut.send(:podfile_from_spec, :ios, '5.0')
dependency = podfile.target_definitions['Pods'].dependencies.first dependency = podfile.target_definitions['Pods'].dependencies.first
dependency.external_source.has_key?(:podspec).should.be.true dependency.external_source.has_key?(:podspec).should.be.true
...@@ -140,6 +207,7 @@ module Pod ...@@ -140,6 +207,7 @@ module Pod
it "respects the local option" do it "respects the local option" do
sut = Validator.new(podspec_path) sut = Validator.new(podspec_path)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
podfile = sut.send(:podfile_from_spec, :ios, '5.0') podfile = sut.send(:podfile_from_spec, :ios, '5.0')
deployment_target = podfile.target_definitions['Pods'].platform.deployment_target deployment_target = podfile.target_definitions['Pods'].platform.deployment_target
deployment_target.to_s.should == "5.0" deployment_target.to_s.should == "5.0"
...@@ -150,6 +218,7 @@ module Pod ...@@ -150,6 +218,7 @@ module Pod
sut.stubs(:check_file_patterns) sut.stubs(:check_file_patterns)
sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated") sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated")
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
sut.validate sut.validate
first = sut.results.map(&:to_s).first first = sut.results.map(&:to_s).first
first.should.include "[xcodebuild]" first.should.include "[xcodebuild]"
...@@ -161,6 +230,7 @@ module Pod ...@@ -161,6 +230,7 @@ module Pod
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:build_pod) sut.stubs(:build_pod)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
sut.validate sut.validate
sut.results.map(&:to_s).first.should.match /source_files.*did not match/ sut.results.map(&:to_s).first.should.match /source_files.*did not match/
sut.result_type.should == :error sut.result_type.should == :error
...@@ -175,6 +245,7 @@ module Pod ...@@ -175,6 +245,7 @@ module Pod
spec = Specification.from_file(file) spec = Specification.from_file(file)
sut = Validator.new(spec) sut = Validator.new(spec)
sut.stubs(:validate_homepage) sut.stubs(:validate_homepage)
sut.stubs(:validate_screenshots)
sut.stubs(:build_pod) sut.stubs(:build_pod)
sut.validate sut.validate
sut.validated?.should.be.true sut.validated?.should.be.true
......
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