Commit 79d2b1f6 authored by Fabio Pelosin's avatar Fabio Pelosin

[Rubocop] Update

parent 9109185a
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by `rubocop --auto-gen-config`
# on 2014-08-14 12:21:44 +0200 using RuboCop version 0.24.1. # on 2014-08-20 23:30:36 +0200 using RuboCop version 0.25.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
Lint/AmbiguousOperator: Lint/AmbiguousOperator:
Enabled: false Enabled: false
# Offense count: 4 # Offense count: 1
# Cop supports --auto-correct.
Lint/BlockAlignment: Lint/BlockAlignment:
Enabled: false Enabled: false
...@@ -18,7 +19,7 @@ Lint/BlockAlignment: ...@@ -18,7 +19,7 @@ Lint/BlockAlignment:
Lint/DefEndAlignment: Lint/DefEndAlignment:
Enabled: false Enabled: false
# Offense count: 3 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Lint/DeprecatedClassMethods: Lint/DeprecatedClassMethods:
Enabled: false Enabled: false
...@@ -28,31 +29,16 @@ Lint/DeprecatedClassMethods: ...@@ -28,31 +29,16 @@ Lint/DeprecatedClassMethods:
Lint/EndAlignment: Lint/EndAlignment:
Enabled: false Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Lint/RescueException:
Enabled: false
# Offense count: 2 # Offense count: 2
Lint/SpaceBeforeFirstArg: Lint/SpaceBeforeFirstArg:
Enabled: false Enabled: false
# Offense count: 5 # Offense count: 1
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Lint/UnusedBlockArgument:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Lint/UnusedMethodArgument: Lint/UnusedMethodArgument:
Enabled: false Enabled: false
# Offense count: 4 # Offense count: 3
Lint/UselessAccessModifier: Lint/UselessAccessModifier:
Enabled: false Enabled: false
...@@ -60,32 +46,51 @@ Lint/UselessAccessModifier: ...@@ -60,32 +46,51 @@ Lint/UselessAccessModifier:
Lint/UselessAssignment: Lint/UselessAssignment:
Enabled: false Enabled: false
# Offense count: 7 # Offense count: 1
Metrics/BlockNesting:
Max: 4
# Offense count: 11
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 326
# Offense count: 12
Metrics/CyclomaticComplexity:
Max: 9
# Offense count: 956
# Configuration parameters: AllowURI.
Metrics/LineLength:
Max: 1060
# Offense count: 104
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 39
# Offense count: 12
Metrics/PerceivedComplexity:
Max: 10
# Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/Alias: Style/Alias:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
Style/AndOr: Style/AndOr:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 1
Style/BlockNesting:
Max: 4
# Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/Blocks: # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BarePercentLiterals:
Enabled: false Enabled: false
# Offense count: 49 # Offense count: 11
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BracesAroundHashParameters: Style/BracesAroundHashParameters:
...@@ -96,69 +101,36 @@ Style/BracesAroundHashParameters: ...@@ -96,69 +101,36 @@ Style/BracesAroundHashParameters:
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
Enabled: false Enabled: false
# Offense count: 12 # Offense count: 3
# Configuration parameters: CountComments.
Style/ClassLength:
Max: 328
# Offense count: 1
# Cop supports --auto-correct.
Style/ClassMethods:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: PreferredMethods. # Configuration parameters: PreferredMethods.
Style/CollectionMethods: Style/CollectionMethods:
Enabled: false Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/ColonMethodCall:
Enabled: false
# Offense count: 7 # Offense count: 7
# Configuration parameters: Keywords. # Configuration parameters: Keywords.
Style/CommentAnnotation: Style/CommentAnnotation:
Enabled: false Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false
# Offense count: 12
Style/CyclomaticComplexity:
Max: 9
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/DeprecatedHashMethods: Style/CommentIndentation:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 1
Style/DoubleNegation: Style/DoubleNegation:
Enabled: false Enabled: false
# Offense count: 24 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/EmptyLines: Style/EmptyLines:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 17
Style/EmptyLinesAroundAccessModifier:
Enabled: false
# Offense count: 164
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/EmptyLinesAroundBody: Style/EmptyLinesAroundBody:
Enabled: false Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Style/EmptyLiteral:
Enabled: false
# Offense count: 1 # Offense count: 1
# Configuration parameters: Exclude. # Configuration parameters: Exclude.
Style/FileName: Style/FileName:
...@@ -174,44 +146,23 @@ Style/For: ...@@ -174,44 +146,23 @@ Style/For:
Style/GlobalVars: Style/GlobalVars:
Enabled: false Enabled: false
# Offense count: 17 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/IndentArray: Style/IndentArray:
Enabled: false Enabled: false
# Offense count: 20 # Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/IndentationConsistency: Style/IndentationConsistency:
Enabled: false Enabled: false
# Offense count: 24 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/IndentationWidth: Style/IndentationWidth:
Enabled: false Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/LineEndConcatenation:
Enabled: false
# Offense count: 952
# Configuration parameters: AllowURI.
Style/LineLength:
Max: 1060
# Offense count: 18
# Cop supports --auto-correct.
Style/MethodCallParentheses: Style/MethodCallParentheses:
Enabled: false Enabled: false
...@@ -221,11 +172,6 @@ Style/MethodCallParentheses: ...@@ -221,11 +172,6 @@ Style/MethodCallParentheses:
Style/MethodDefParentheses: Style/MethodDefParentheses:
Enabled: false Enabled: false
# Offense count: 104
# Configuration parameters: CountComments.
Style/MethodLength:
Max: 39
# Offense count: 1 # Offense count: 1
Style/MultilineIfThen: Style/MultilineIfThen:
Enabled: false Enabled: false
...@@ -234,56 +180,29 @@ Style/MultilineIfThen: ...@@ -234,56 +180,29 @@ Style/MultilineIfThen:
Style/MultilineTernaryOperator: Style/MultilineTernaryOperator:
Enabled: false Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Style/NegatedIf:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/NegatedWhile: Style/NegatedWhile:
Enabled: false Enabled: false
# Offense count: 10
# Cop supports --auto-correct.
Style/NilComparison:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IncludeSemanticChanges.
Style/NonNilCheck:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/Not: Style/Not:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: AllowSafeAssignment.
Style/ParenthesesAroundCondition:
Enabled: false
# Offense count: 49
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters. # Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters: Style/PercentLiteralDelimiters:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 4
# Cop supports --auto-correct.
Style/PerlBackrefs:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues. # Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn: Style/RedundantReturn:
Enabled: false Enabled: false
# Offense count: 3 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/RedundantSelf: Style/RedundantSelf:
Enabled: false Enabled: false
...@@ -297,104 +216,84 @@ Style/RegexpLiteral: ...@@ -297,104 +216,84 @@ Style/RegexpLiteral:
Style/SelfAssignment: Style/SelfAssignment:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: AllowIfMethodIsEmpty.
Style/SingleLineMethods:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg: Style/SingleSpaceBeforeFirstArg:
Enabled: false Enabled: false
# Offense count: 14 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceAfterComma: Style/SpaceAfterComma:
Enabled: false Enabled: false
# Offense count: 2 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceAfterControlKeyword: Style/SpaceAfterControlKeyword:
Enabled: false Enabled: false
# Offense count: 15 # Offense count: 6
# Cop supports --auto-correct.
Style/SpaceAroundOperators:
Enabled: false
# Offense count: 13
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces: Style/SpaceBeforeBlockBraces:
Enabled: false Enabled: false
# Offense count: 2 # Offense count: 11
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
Enabled: false
# Offense count: 35
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces: Style/SpaceInsideBlockBraces:
Enabled: false Enabled: false
# Offense count: 25 # Offense count: 4
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceInsideBrackets: Style/SpaceInsideBrackets:
Enabled: false Enabled: false
# Offense count: 89 # Offense count: 34
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Style/SpaceInsideHashLiteralBraces: Style/SpaceInsideHashLiteralBraces:
Enabled: false Enabled: false
# Offense count: 40 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceInsideParens: Style/SpaceInsideParens:
Enabled: false Enabled: false
# Offense count: 1580 # Offense count: 160
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals: Style/StringLiterals:
Enabled: false Enabled: false
# Offense count: 30 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines: Style/TrailingBlankLines:
Enabled: false Enabled: false
# Offense count: 86 # Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma: Style/TrailingComma:
Enabled: false Enabled: false
# Offense count: 32 # Offense count: 22
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/TrailingWhitespace: Style/TrailingWhitespace:
Enabled: false Enabled: false
# Offense count: 5 # Offense count: 4
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
Style/TrivialAccessors: Style/TrivialAccessors:
Enabled: false Enabled: false
# Offense count: 10
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Enabled: false
# Offense count: 1 # Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName: Style/VariableName:
Enabled: false Enabled: false
# Offense count: 19 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/WordArray: Style/WordArray:
MinSize: 4 MinSize: 2
...@@ -28,14 +28,14 @@ GIT ...@@ -28,14 +28,14 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-try.git remote: https://github.com/CocoaPods/cocoapods-try.git
revision: f91e069f1f1b22cef5bbd788835f1803e6dce24e revision: 59a225cd4dd1868da4be7c4cc870cae427f04bf9
branch: master branch: master
specs: specs:
cocoapods-try (0.3.0) cocoapods-try (0.3.0)
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-trunk.git remote: https://github.com/CocoaPods/cocoapods-trunk.git
revision: ed920119fa850d66ee8fbe1873ae9ee0d4e46905 revision: 62bca8ec7073fc59d4137818bd78e0bbc8b1718f
branch: master branch: master
specs: specs:
cocoapods-trunk (0.1.4) cocoapods-trunk (0.1.4)
...@@ -45,7 +45,7 @@ GIT ...@@ -45,7 +45,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-plugins.git remote: https://github.com/CocoaPods/cocoapods-plugins.git
revision: b989190a02875d16482d2e440a34a54b8559996c revision: f1364dd91ea334e46b2f37455aef46147d14575a
branch: master branch: master
specs: specs:
cocoapods-plugins (0.2.0) cocoapods-plugins (0.2.0)
...@@ -53,14 +53,14 @@ GIT ...@@ -53,14 +53,14 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: 025395e3fd53d23b74b9f55ac0a5750fa92f82e3 revision: a8710a42b1ce379fb2afe66ce9f98a08b58fb482
branch: master branch: master
specs: specs:
cocoapods-downloader (0.6.1) cocoapods-downloader (0.6.1)
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: d696bf6a34eb837d8e89fc1fc9170cff1a1256e4 revision: f557903817f29000819d4b1b754e6dd667587c30
branch: master branch: master
specs: specs:
cocoapods-core (0.33.1) cocoapods-core (0.33.1)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
if RUBY_VERSION > '1.8.7' && Encoding.default_external != Encoding::UTF_8 if RUBY_VERSION > '1.8.7' && Encoding.default_external != Encoding::UTF_8
puts "\e[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding." puts "\e[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding."
if ENV["TRAVIS"] if ENV['TRAVIS']
puts <<-DOC puts <<-DOC
Consider adding the following settings to .travis.yml Consider adding the following settings to .travis.yml
...@@ -19,12 +19,12 @@ end ...@@ -19,12 +19,12 @@ end
if $PROGRAM_NAME == __FILE__ && !ENV['COCOAPODS_NO_BUNDLER'] if $PROGRAM_NAME == __FILE__ && !ENV['COCOAPODS_NO_BUNDLER']
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
require "rubygems" require 'rubygems'
require "bundler/setup" require 'bundler/setup'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
elsif ENV['COCOAPODS_NO_BUNDLER'] elsif ENV['COCOAPODS_NO_BUNDLER']
require "rubygems" require 'rubygems'
gem "cocoapods" gem 'cocoapods'
end end
STDOUT.sync = true if ENV['CP_STDOUT_SYNC'] == 'TRUE' STDOUT.sync = true if ENV['CP_STDOUT_SYNC'] == 'TRUE'
......
...@@ -52,7 +52,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS ...@@ -52,7 +52,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS
"<%= pod_bin %>" "<%= pod_bin %>"
"<%= ruby_bin %>" "<%= ruby_bin %>"
) )
(regex (regex
<% prefixes.each do |prefix| %> <% prefixes.each do |prefix| %>
#"^<%= prefix %>/*" #"^<%= prefix %>/*"
<% end %> <% end %>
...@@ -105,9 +105,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS ...@@ -105,9 +105,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS
(deny default) (deny default)
EOS EOS
class Profile class Profile
def pod_bin def pod_bin
File.expand_path('../pod', __FILE__) File.expand_path('../pod', __FILE__)
end end
...@@ -159,14 +157,12 @@ class Profile ...@@ -159,14 +157,12 @@ class Profile
def generate def generate
ERB.new(PROFILE_ERB_TEMPLATE, 0, '>').result(binding) ERB.new(PROFILE_ERB_TEMPLATE, 0, '>').result(binding)
end end
end end
# Ensure the `pod` bin doesn’t think it needs to use Bundler. # Ensure the `pod` bin doesn’t think it needs to use Bundler.
ENV['COCOAPODS_NO_BUNDLER'] = '1' ENV['COCOAPODS_NO_BUNDLER'] = '1'
profile = Profile.new profile = Profile.new
#puts profile.generate # puts profile.generate
command = ['/usr/bin/sandbox-exec', '-p', profile.generate, profile.pod_bin, *ARGV] command = ['/usr/bin/sandbox-exec', '-p', profile.generate, profile.pod_bin, *ARGV]
exec(*command) exec(*command)
...@@ -66,7 +66,6 @@ module Pod ...@@ -66,7 +66,6 @@ module Pod
autoload :LibraryRepresentation, 'cocoapods/hooks/library_representation' autoload :LibraryRepresentation, 'cocoapods/hooks/library_representation'
autoload :PodRepresentation, 'cocoapods/hooks/pod_representation' autoload :PodRepresentation, 'cocoapods/hooks/pod_representation'
end end
end end
if ENV['COCOA_PODS_ENV'] == 'development' if ENV['COCOA_PODS_ENV'] == 'development'
......
...@@ -7,7 +7,6 @@ module Pod ...@@ -7,7 +7,6 @@ module Pod
end end
class Command < CLAide::Command class Command < CLAide::Command
require 'cocoapods/command/help' require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication' require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib' require 'cocoapods/command/lib'
...@@ -44,14 +43,14 @@ module Pod ...@@ -44,14 +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 help! 'You cannot run CocoaPods as root.' if Process.uid == 0
super(argv) super(argv)
UI.print_warnings UI.print_warnings
end end
def self.report_error(exception) def self.report_error(exception)
if exception.is_a?(Interrupt) if exception.is_a?(Interrupt)
puts "[!] Cancelled".red puts '[!] Cancelled'.red
Config.instance.verbose? ? raise : exit(1) Config.instance.verbose? ? raise : exit(1)
else else
if ENV['COCOA_PODS_ENV'] != 'development' if ENV['COCOA_PODS_ENV'] != 'development'
...@@ -76,9 +75,9 @@ module Pod ...@@ -76,9 +75,9 @@ module Pod
def initialize(argv) def initialize(argv)
super super
config.silent = argv.flag?('silent', config.silent) config.silent = argv.flag?('silent', config.silent)
config.verbose = self.verbose? unless self.verbose.nil? config.verbose = self.verbose? unless verbose.nil?
unless self.ansi_output? unless self.ansi_output?
String.send(:define_method, :colorize) { |string , _| string } String.send(:define_method, :colorize) { |string, _| string }
end end
end end
...@@ -113,4 +112,3 @@ module Pod ...@@ -113,4 +112,3 @@ module Pod
end end
end end
end end
...@@ -3,7 +3,7 @@ module Pod ...@@ -3,7 +3,7 @@ module Pod
class Help < Command class Help < Command
self.summary = 'Show help for the given command.' self.summary = 'Show help for the given command.'
self.arguments = [ self.arguments = [
CLAide::Argument.new('COMMAND', false) CLAide::Argument.new('COMMAND', false),
] ]
def initialize(argv) def initialize(argv)
...@@ -17,9 +17,7 @@ module Pod ...@@ -17,9 +17,7 @@ module Pod
private private
def help_command attr_reader :help_command
@help_command
end
end end
end end
end end
...@@ -4,7 +4,6 @@ require 'active_support/core_ext/string/strip' ...@@ -4,7 +4,6 @@ require 'active_support/core_ext/string/strip'
module Pod module Pod
class Command class Command
class Init < Command class Init < Command
self.summary = 'Generate a Podfile for the current directory.' self.summary = 'Generate a Podfile for the current directory.'
self.description = <<-DESC self.description = <<-DESC
Creates a Podfile for the current directory if none currently exists. If Creates a Podfile for the current directory if none currently exists. If
...@@ -18,11 +17,11 @@ module Pod ...@@ -18,11 +17,11 @@ module Pod
`~/.cocoapods/templates` folder. `~/.cocoapods/templates` folder.
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('XCODEPROJ', :false) CLAide::Argument.new('XCODEPROJ', :false),
] ]
def initialize(argv) def initialize(argv)
@podfile_path = Pathname.pwd + "Podfile" @podfile_path = Pathname.pwd + 'Podfile'
@project_path = argv.shift_argument @project_path = argv.shift_argument
@project_paths = Pathname.pwd.children.select { |pn| pn.extname == '.xcodeproj' } @project_paths = Pathname.pwd.children.select { |pn| pn.extname == '.xcodeproj' }
super super
...@@ -30,13 +29,13 @@ module Pod ...@@ -30,13 +29,13 @@ module Pod
def validate! def validate!
super super
raise Informative, "Existing Podfile found in directory" unless config.podfile_path_in_dir(Pathname.pwd).nil? raise Informative, 'Existing Podfile found in directory' unless config.podfile_path_in_dir(Pathname.pwd).nil?
if @project_path if @project_path
help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path
project_path = @project_path project_path = @project_path
else else
raise Informative, "No xcode project found, please specify one" unless @project_paths.length > 0 raise Informative, 'No xcode project found, please specify one' unless @project_paths.length > 0
raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1 raise Informative, 'Multiple xcode projects found, please specify one' unless @project_paths.length == 1
project_path = @project_paths.first project_path = @project_paths.first
end end
@xcode_project = Xcodeproj::Project.open(project_path) @xcode_project = Xcodeproj::Project.open(project_path)
...@@ -82,12 +81,11 @@ module Pod ...@@ -82,12 +81,11 @@ module Pod
target_module << "\nend\n" target_module << "\nend\n"
end end
def template_contents(path) def template_contents(path)
if path.exist? if path.exist?
path.read.chomp.lines.map{ |line| " #{line}" }.join("\n") path.read.chomp.lines.map { |line| " #{line}" }.join("\n")
else else
String.new ''
end end
end end
end end
......
module Pod module Pod
class Command class Command
class IPC < Command class IPC < Command
self.abstract_command = true self.abstract_command = true
self.summary = 'Inter-process communication' self.summary = 'Inter-process communication'
...@@ -12,11 +11,10 @@ module Pod ...@@ -12,11 +11,10 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Spec < IPC class Spec < IPC
self.summary = 'Converts a podspec to JSON.' self.summary = 'Converts a podspec to JSON.'
self.description = 'Converts a podspec to JSON and prints it to STDOUT.' self.description = 'Converts a podspec to JSON and prints it to STDOUT.'
self.arguments = [ self.arguments = [
CLAide::Argument.new('PATH', true) CLAide::Argument.new('PATH', true),
] ]
def initialize(argv) def initialize(argv)
...@@ -26,24 +24,22 @@ module Pod ...@@ -26,24 +24,22 @@ module Pod
def validate! def validate!
super super
help! "A specification path is required." unless @path help! 'A specification path is required.' unless @path
end end
def run def run
spec = Specification.from_file(@path) spec = Specification.from_file(@path)
output_pipe.puts spec.to_json output_pipe.puts spec.to_json
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Podfile < IPC class Podfile < IPC
self.summary = 'Converts a Podfile to YAML.' self.summary = 'Converts a Podfile to YAML.'
self.description = 'Converts a Podfile to YAML and prints it to STDOUT.' self.description = 'Converts a Podfile to YAML and prints it to STDOUT.'
self.arguments = [ self.arguments = [
CLAide::Argument.new('PATH', true) CLAide::Argument.new('PATH', true),
] ]
def initialize(argv) def initialize(argv)
...@@ -53,20 +49,18 @@ module Pod ...@@ -53,20 +49,18 @@ module Pod
def validate! def validate!
super super
help! "A Podfile path is required." unless @path help! 'A Podfile path is required.' unless @path
end end
def run def run
podfile = Pod::Podfile.from_file(@path) podfile = Pod::Podfile.from_file(@path)
output_pipe.puts podfile.to_yaml output_pipe.puts podfile.to_yaml
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class List < IPC class List < IPC
self.summary = 'Lists the specifications known to CocoaPods.' self.summary = 'Lists the specifications known to CocoaPods.'
self.description = <<-DESC self.description = <<-DESC
Prints to STDOUT a YAML dictionary where the keys are the name of the Prints to STDOUT a YAML dictionary where the keys are the name of the
...@@ -99,13 +93,11 @@ module Pod ...@@ -99,13 +93,11 @@ module Pod
end end
output_pipe.puts result.to_yaml output_pipe.puts result.to_yaml
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class UpdateSearchIndex < IPC class UpdateSearchIndex < IPC
self.summary = 'Updates the search index.' self.summary = 'Updates the search index.'
self.description = <<-DESC self.description = <<-DESC
Updates the search index and prints its path to standard output. Updates the search index and prints its path to standard output.
...@@ -123,13 +115,11 @@ module Pod ...@@ -123,13 +115,11 @@ module Pod
SourcesManager.updated_search_index SourcesManager.updated_search_index
output_pipe.puts(SourcesManager.search_index_path) output_pipe.puts(SourcesManager.search_index_path)
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Repl < IPC class Repl < IPC
END_OF_OUTPUT_SIGNAL = "\n\r" END_OF_OUTPUT_SIGNAL = "\n\r"
self.summary = 'The repl listens to commands on standard input.' self.summary = 'The repl listens to commands on standard input.'
...@@ -172,11 +162,9 @@ module Pod ...@@ -172,11 +162,9 @@ module Pod
signal_end_of_output signal_end_of_output
end end
end end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
...@@ -6,8 +6,8 @@ module Pod ...@@ -6,8 +6,8 @@ module Pod
def self.options def self.options
[[ [[
"--update", "Run `pod repo update` before listing", '--update', 'Run `pod repo update` before listing',
"--stats", "Show additional stats (like GitHub watchers and forks)" '--stats', 'Show additional stats (like GitHub watchers and forks)'
]].concat(super) ]].concat(super)
end end
...@@ -31,7 +31,7 @@ module Pod ...@@ -31,7 +31,7 @@ module Pod
def update_if_necessary! def update_if_necessary!
if @update && config.verbose? if @update && config.verbose?
UI.section("\nUpdating Spec Repositories\n".yellow) do UI.section("\nUpdating Spec Repositories\n".yellow) do
Repo.new(ARGV.new(["update"])).run Repo.new(ARGV.new(['update'])).run
end end
end end
end end
...@@ -44,9 +44,9 @@ module Pod ...@@ -44,9 +44,9 @@ module Pod
def run def run
update_if_necessary! update_if_necessary!
days = [1,2,3,5,8] days = [1, 2, 3, 5, 8]
dates, groups = {}, {} dates, groups = {}, {}
days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d} days.each { |d| dates[d] = Time.now - 60 * 60 * 24 * d }
sets = SourcesManager.all_sets sets = SourcesManager.all_sets
statistics_provider = Config.instance.spec_statistics_provider statistics_provider = Config.instance.spec_statistics_provider
creation_dates = statistics_provider.creation_dates(sets) creation_dates = statistics_provider.creation_dates(sets)
...@@ -64,8 +64,8 @@ module Pod ...@@ -64,8 +64,8 @@ module Pod
days.reverse.each do |d| days.reverse.each do |d|
sets = groups[d] sets = groups[d]
next unless sets next unless sets
UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do UI.section("\nPods added in the last #{'day'.pluralize(d)}".yellow) do
sorted = sets.sort_by {|s| creation_dates[s.name]} sorted = sets.sort_by { |s| creation_dates[s.name] }
mode = @stats ? :stats : :name mode = @stats ? :stats : :name
sorted.each { |set| UI.pod(set, mode, statistics_provider) } sorted.each { |set| UI.pod(set, mode, statistics_provider) }
end end
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
DESC DESC
def self.options def self.options
[["--no-repo-update", "Skip running `pod repo update` before install"]].concat(super) [['--no-repo-update', 'Skip running `pod repo update` before install']].concat(super)
end end
def initialize(argv) def initialize(argv)
...@@ -23,11 +23,10 @@ module Pod ...@@ -23,11 +23,10 @@ module Pod
# @todo fix. # @todo fix.
# #
def run def run
if updates.empty? if updates.empty?
UI.puts "No updates are available.".yellow UI.puts 'No updates are available.'.yellow
else else
UI.section "The following updates are available:" do UI.section 'The following updates are available:' do
updates.each do |(name, from_version, to_version)| updates.each do |(name, from_version, to_version)|
UI.puts "- #{name} #{from_version} -> #{to_version}" UI.puts "- #{name} #{from_version} -> #{to_version}"
end end
...@@ -46,7 +45,6 @@ module Pod ...@@ -46,7 +45,6 @@ module Pod
end end
end end
end end
end end
private private
...@@ -97,9 +95,6 @@ module Pod ...@@ -97,9 +95,6 @@ module Pod
config.lockfile config.lockfile
end end
end end
end end
end end
end end
module Pod module Pod
class Command class Command
# Provides support the common behaviour of the `install` and `update` # Provides support the common behaviour of the `install` and `update`
# commands. # commands.
# #
...@@ -8,9 +7,9 @@ module Pod ...@@ -8,9 +7,9 @@ module Pod
module Options module Options
def options def options
[ [
["--no-clean", "Leave SCM dirs like `.git` and `.svn` intact after downloading"], ['--no-clean', 'Leave SCM dirs like `.git` and `.svn` intact after downloading'],
["--no-integrate", "Skip integration of the Pods libraries in the Xcode project(s)"], ['--no-integrate', 'Skip integration of the Pods libraries in the Xcode project(s)'],
["--no-repo-update", "Skip running `pod repo update` before install"], ['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super) ].concat(super)
end end
end end
...@@ -105,19 +104,17 @@ module Pod ...@@ -105,19 +104,17 @@ module Pod
missing_pods = @pods.select { |pod| !config.lockfile.pod_names.include?(pod) } missing_pods = @pods.select { |pod| !config.lockfile.pod_names.include?(pod) }
if missing_pods.length > 0 if missing_pods.length > 0
raise Informative, (missing_pods.length > 1 \ raise Informative, (missing_pods.length > 1 \
? "Pods %s are not installed and cannot be updated" \ ? 'Pods %s are not installed and cannot be updated' \
: "Pod %s is not installed and cannot be updated" : 'Pod %s is not installed and cannot be updated'
) % missing_pods.map { |p| "`#{p}`" }.join(', ') ) % missing_pods.map { |p| "`#{p}`" }.join(', ')
end end
run_install_with_update(:pods => @pods) run_install_with_update(:pods => @pods)
else else
UI.puts "Update all pods".yellow unless @pods UI.puts 'Update all pods'.yellow unless @pods
run_install_with_update(true) run_install_with_update(true)
end end
end end
end end
end end
end end
...@@ -3,7 +3,6 @@ module Pod ...@@ -3,7 +3,6 @@ module Pod
class Push < Command class Push < Command
self.summary = 'Temporary alias for the `pod repo push` command' self.summary = 'Temporary alias for the `pod repo push` command'
def initialize(argv) def initialize(argv)
@push_command = Repo::Push.new(argv) @push_command = Repo::Push.new(argv)
super super
......
...@@ -19,14 +19,14 @@ module Pod ...@@ -19,14 +19,14 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('NAME', true), CLAide::Argument.new('NAME', true),
CLAide::Argument.new('URL', true), CLAide::Argument.new('URL', true),
CLAide::Argument.new('BRANCH', false) CLAide::Argument.new('BRANCH', false),
] ]
def self.options def self.options
[ [
["--shallow", "Create a shallow clone (fast clone, but no push capabilities)"], ['--shallow', 'Create a shallow clone (fast clone, but no push capabilities)'],
].concat(super) ].concat(super)
end end
...@@ -39,7 +39,7 @@ module Pod ...@@ -39,7 +39,7 @@ module Pod
def validate! def validate!
super super
unless @name && @url unless @name && @url
help! "Adding a repo needs a `NAME` and a `URL`." help! 'Adding a repo needs a `NAME` and a `URL`.'
end end
end end
...@@ -69,7 +69,7 @@ module Pod ...@@ -69,7 +69,7 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('NAME', false) CLAide::Argument.new('NAME', false),
] ]
def initialize(argv) def initialize(argv)
...@@ -94,11 +94,11 @@ module Pod ...@@ -94,11 +94,11 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new(%w(NAME DIRECTORY), false) CLAide::Argument.new(%w(NAME DIRECTORY), false),
] ]
def self.options def self.options
[["--only-errors", "Lint presents only the errors"]].concat(super) [['--only-errors', 'Lint presents only the errors']].concat(super)
end end
def initialize(argv) def initialize(argv)
...@@ -114,16 +114,16 @@ module Pod ...@@ -114,16 +114,16 @@ module Pod
# #
def run def run
if @name if @name
dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ] dirs = File.exist?(@name) ? [Pathname.new(@name)] : [dir]
else else
dirs = config.repos_dir.children.select {|c| c.directory?} dirs = config.repos_dir.children.select { |c| c.directory? }
end end
dirs.each do |dir| dirs.each do |dir|
SourcesManager.check_version_information(dir) SourcesManager.check_version_information(dir)
UI.puts "\nLinting spec repo `#{dir.realpath.basename}`\n".yellow UI.puts "\nLinting spec repo `#{dir.realpath.basename}`\n".yellow
validator = Source::HealthReporter.new(dir) validator = Source::HealthReporter.new(dir)
validator.pre_check do |name, version| validator.pre_check do |_name, _version|
UI.print '.' UI.print '.'
end end
report = validator.analyze report = validator.analyze
...@@ -144,7 +144,7 @@ module Pod ...@@ -144,7 +144,7 @@ module Pod
UI.puts "Analyzed #{report.analyzed_paths.count} podspecs files.\n\n" UI.puts "Analyzed #{report.analyzed_paths.count} podspecs files.\n\n"
if report.pods_by_error.count.zero? if report.pods_by_error.count.zero?
UI.puts "All the specs passed validation.".green << "\n\n" UI.puts 'All the specs passed validation.'.green << "\n\n"
else else
raise Informative, "#{report.pods_by_error.count} podspecs failed validation." raise Informative, "#{report.pods_by_error.count} podspecs failed validation."
end end
...@@ -162,7 +162,7 @@ module Pod ...@@ -162,7 +162,7 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('NAME', true) CLAide::Argument.new('NAME', true),
] ]
def initialize(argv) def initialize(argv)
...@@ -175,7 +175,7 @@ module Pod ...@@ -175,7 +175,7 @@ module Pod
help! 'Deleting a repo needs a `NAME`.' unless @name help! 'Deleting a repo needs a `NAME`.' unless @name
help! "repo #{@name} does not exist" unless File.directory?(dir) help! "repo #{@name} does not exist" unless File.directory?(dir)
help! "You do not have permission to delete the #{@name} repository." \ help! "You do not have permission to delete the #{@name} repository." \
"Perhaps try prefixing this command with sudo." unless File.writable?(dir) 'Perhaps try prefixing this command with sudo.' unless File.writable?(dir)
end end
def run def run
...@@ -194,4 +194,3 @@ module Pod ...@@ -194,4 +194,3 @@ module Pod
end end
end end
end end
...@@ -15,13 +15,13 @@ module Pod ...@@ -15,13 +15,13 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('REPO', true), CLAide::Argument.new('REPO', true),
CLAide::Argument.new('NAME.podspec', false) CLAide::Argument.new('NAME.podspec', false),
] ]
def self.options def self.options
[ ["--allow-warnings", "Allows pushing even if there are warnings"], [['--allow-warnings', 'Allows pushing even if there are warnings'],
["--local-only", "Does not perform the step of pushing REPO to its remote"] ].concat(super) ['--local-only', 'Does not perform the step of pushing REPO to its remote']].concat(super)
end end
def initialize(argv) def initialize(argv)
...@@ -34,7 +34,7 @@ module Pod ...@@ -34,7 +34,7 @@ module Pod
def validate! def validate!
super super
help! "A spec-repo name is required." unless @repo help! 'A spec-repo name is required.' unless @repo
end end
def run def run
...@@ -69,15 +69,14 @@ module Pod ...@@ -69,15 +69,14 @@ module Pod
end end
if is_master_repo if is_master_repo
raise Informative, "To push to the CocoaPods master repo use " \ raise Informative, 'To push to the CocoaPods master repo use ' \
"the `pod trunk push` command.\n\nIf you are using a fork of " \ "the `pod trunk push` command.\n\nIf you are using a fork of " \
"the master repo for private purposes we recommend to migrate " \ 'the master repo for private purposes we recommend to migrate ' \
"to a clean private repo. To disable this check remove the " \ 'to a clean private repo. To disable this check remove the ' \
"remote pointing to the CocoaPods master repo." 'remote pointing to the CocoaPods master repo.'
end end
end end
# Performs a full lint against the podspecs. # Performs a full lint against the podspecs.
# #
def validate_podspec_files def validate_podspec_files
...@@ -87,7 +86,7 @@ module Pod ...@@ -87,7 +86,7 @@ module Pod
validator.only_errors = @allow_warnings validator.only_errors = @allow_warnings
begin begin
validator.validate validator.validate
rescue Exception rescue
raise Informative, "The `#{podspec}` specification does not validate." raise Informative, "The `#{podspec}` specification does not validate."
end end
raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated? raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
...@@ -143,7 +142,7 @@ module Pod ...@@ -143,7 +142,7 @@ module Pod
FileUtils.cp(spec_file, output_path) FileUtils.cp(spec_file, output_path)
Dir.chdir(repo_dir) do Dir.chdir(repo_dir) do
# only commit if modified # only commit if modified
if git!("status --porcelain 2>&1").include?(spec.name) if git!('status --porcelain 2>&1').include?(spec.name)
UI.puts " - #{message}" UI.puts " - #{message}"
git!("add #{spec.name}") git!("add #{spec.name}")
git!("commit --no-verify -m '#{message}'") git!("commit --no-verify -m '#{message}'")
...@@ -187,7 +186,7 @@ module Pod ...@@ -187,7 +186,7 @@ module Pod
# @return [Array<Pathname>] The path of the specifications to push. # @return [Array<Pathname>] The path of the specifications to push.
# #
def podspec_files def podspec_files
files = Pathname.glob(@podspec || "*.podspec") files = Pathname.glob(@podspec || '*.podspec')
raise Informative, "Couldn't find any .podspec file in current directory" if files.empty? raise Informative, "Couldn't find any .podspec file in current directory" if files.empty?
files files
end end
...@@ -199,7 +198,6 @@ module Pod ...@@ -199,7 +198,6 @@ module Pod
end end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
end end
end end
end end
......
...@@ -10,16 +10,16 @@ module Pod ...@@ -10,16 +10,16 @@ module Pod
DESC DESC
self.arguments = [ self.arguments = [
CLAide::Argument.new('QUERY', true) CLAide::Argument.new('QUERY', true),
] ]
def self.options def self.options
[ [
["--full", "Search by name, summary, and description"], ['--full', 'Search by name, summary, and description'],
["--stats", "Show additional stats (like GitHub watchers and forks)"], ['--stats', 'Show additional stats (like GitHub watchers and forks)'],
["--ios", "Restricts the search to Pods supported on iOS"], ['--ios', 'Restricts the search to Pods supported on iOS'],
["--osx", "Restricts the search to Pods supported on OS X"], ['--osx', 'Restricts the search to Pods supported on OS X'],
["--web", "Searches on cocoapods.org"] ['--web', 'Searches on cocoapods.org'],
].concat(super.reject { |option, _| option == '--silent' }) ].concat(super.reject { |option, _| option == '--silent' })
end end
...@@ -36,13 +36,13 @@ module Pod ...@@ -36,13 +36,13 @@ module Pod
def validate! def validate!
super super
help! "A search query is required." unless @query help! 'A search query is required.' unless @query
unless @web unless @web
begin begin
/#{@query.join(' ').strip}/ /#{@query.join(' ').strip}/
rescue RegexpError rescue RegexpError
help! "A valid regular expression is required." help! 'A valid regular expression is required.'
end end
end end
end end
...@@ -62,9 +62,9 @@ module Pod ...@@ -62,9 +62,9 @@ module Pod
query_parameter = [ query_parameter = [
('on:osx' if @supported_on_osx), ('on:osx' if @supported_on_osx),
('on:ios' if @supported_on_ios), ('on:ios' if @supported_on_ios),
@query @query,
].compact.flatten.join(' ') ].compact.flatten.join(' ')
url = "http://cocoapods.org/?q=#{CGI.escape(query_parameter).gsub("+", "%20")}" url = "http://cocoapods.org/?q=#{CGI.escape(query_parameter).gsub('+', '%20')}"
UI.puts("Opening #{url}") UI.puts("Opening #{url}")
open!(url) open!(url)
end end
...@@ -72,10 +72,10 @@ module Pod ...@@ -72,10 +72,10 @@ module Pod
def local_search def local_search
sets = SourcesManager.search_by_name(@query.join(' ').strip, @full_text_search) sets = SourcesManager.search_by_name(@query.join(' ').strip, @full_text_search)
if @supported_on_ios if @supported_on_ios
sets.reject!{ |set| !set.specification.available_platforms.map(&:name).include?(:ios) } sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:ios) }
end end
if @supported_on_osx if @supported_on_osx
sets.reject!{ |set| !set.specification.available_platforms.map(&:name).include?(:osx) } sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:osx) }
end end
statistics_provider = Config.instance.spec_statistics_provider statistics_provider = Config.instance.spec_statistics_provider
...@@ -91,7 +91,6 @@ module Pod ...@@ -91,7 +91,6 @@ module Pod
end end
end end
end end
end end
end end
end end
...@@ -16,8 +16,8 @@ module Pod ...@@ -16,8 +16,8 @@ module Pod
def self.options def self.options
[ [
["--no-shallow", "Clone full history so push will work"], ['--no-shallow', 'Clone full history so push will work'],
["--push", "Use this option to enable push access once granted"], ['--push', 'Use this option to enable push access once granted'],
].concat(super) ].concat(super)
end end
...@@ -31,7 +31,7 @@ module Pod ...@@ -31,7 +31,7 @@ module Pod
end end
def run def run
UI.section "Setting up CocoaPods master repo" do UI.section 'Setting up CocoaPods master repo' do
if master_repo_dir.exist? if master_repo_dir.exist?
set_master_repo_url set_master_repo_url
set_master_repo_branch set_master_repo_branch
...@@ -43,7 +43,7 @@ module Pod ...@@ -43,7 +43,7 @@ module Pod
end end
end end
access_type = push? ? "push" : "read-only" access_type = push? ? 'push' : 'read-only'
UI.puts "Setup completed (#{access_type} access)".green UI.puts "Setup completed (#{access_type} access)".green
end end
...@@ -103,7 +103,7 @@ module Pod ...@@ -103,7 +103,7 @@ module Pod
# #
def set_master_repo_branch def set_master_repo_branch
Dir.chdir(master_repo_dir) do Dir.chdir(master_repo_dir) do
git("checkout master") git('checkout master')
end end
end end
......
...@@ -3,7 +3,6 @@ require 'cocoapods-downloader' ...@@ -3,7 +3,6 @@ require 'cocoapods-downloader'
module Pod module Pod
module Downloader module Downloader
class Base class Base
override_api do override_api do
def execute_command(executable, command, raise_on_failure = false) def execute_command(executable, command, raise_on_failure = false)
......
module Pod module Pod
# Module which provides support for running executables. # Module which provides support for running executables.
# #
# In a class it can be used as: # In a class it can be used as:
...@@ -12,7 +11,6 @@ module Pod ...@@ -12,7 +11,6 @@ module Pod
# output of the command. # output of the command.
# #
module Executable module Executable
# Creates the methods for the executable with the given name. # Creates the methods for the executable with the given name.
# #
# @param [Symbol] name # @param [Symbol] name
...@@ -21,12 +19,11 @@ module Pod ...@@ -21,12 +19,11 @@ module Pod
# @return [void] # @return [void]
# #
def executable(name) def executable(name)
define_method(name) do |command| define_method(name) do |command|
Executable.execute_command(name, command, false) Executable.execute_command(name, command, false)
end end
define_method(name.to_s + "!") do |command| define_method(name.to_s + '!') do |command|
Executable.execute_command(name, command, true) Executable.execute_command(name, command, true)
end end
end end
...@@ -51,7 +48,6 @@ module Pod ...@@ -51,7 +48,6 @@ module Pod
# @todo Find a way to display the live output of the commands. # @todo Find a way to display the live output of the commands.
# #
def self.execute_command(executable, command, raise_on_failure) def self.execute_command(executable, command, raise_on_failure)
bin = `which #{executable}`.strip bin = `which #{executable}`.strip
raise Informative, "Unable to locate the executable `#{executable}`" if bin.empty? raise Informative, "Unable to locate the executable `#{executable}`" if bin.empty?
...@@ -66,7 +62,7 @@ module Pod ...@@ -66,7 +62,7 @@ module Pod
stdout, stderr = Indenter.new, Indenter.new stdout, stderr = Indenter.new, Indenter.new
end end
options = {:stdout => stdout, :stderr => stderr, :status => true} options = { :stdout => stdout, :stderr => stderr, :status => true }
status = Open4.spawn(full_command, options) status = Open4.spawn(full_command, options)
output = stdout.join("\n") + stderr.join("\n") output = stdout.join("\n") + stderr.join("\n")
unless status.success? unless status.success?
...@@ -85,7 +81,6 @@ module Pod ...@@ -85,7 +81,6 @@ module Pod
# the UI indentation lever. # the UI indentation lever.
# #
class Indenter < ::Array class Indenter < ::Array
# @return [Fixnum] The indentation level of the UI. # @return [Fixnum] The indentation level of the UI.
# #
attr_accessor :indent attr_accessor :indent
......
...@@ -4,12 +4,10 @@ require 'cocoapods/external_sources/path_source' ...@@ -4,12 +4,10 @@ require 'cocoapods/external_sources/path_source'
require 'cocoapods/external_sources/podspec_source' require 'cocoapods/external_sources/podspec_source'
module Pod module Pod
# Provides support for initializing the correct concrete class of an external # Provides support for initializing the correct concrete class of an external
# source. # source.
# #
module ExternalSources module ExternalSources
# @return [AbstractExternalSource] an initialized instance of the concrete # @return [AbstractExternalSource] an initialized instance of the concrete
# external source class associated with the option specified in the # external source class associated with the option specified in the
# hash. # hash.
...@@ -34,8 +32,8 @@ module Pod ...@@ -34,8 +32,8 @@ module Pod
elsif params.key?(:path) elsif params.key?(:path)
PathSource PathSource
elsif params.key?(:local) elsif params.key?(:local)
UI.warn "The `:local` option of the Podfile has been " \ UI.warn 'The `:local` option of the Podfile has been ' \
"renamed to `:path` and it is deprecated." 'renamed to `:path` and it is deprecated.'
PathSource PathSource
elsif Downloader.strategy_from_options(params) elsif Downloader.strategy_from_options(params)
DownloaderSource DownloaderSource
......
module Pod module Pod
module ExternalSources module ExternalSources
# Abstract class that defines the common behaviour of external sources. # Abstract class that defines the common behaviour of external sources.
# #
class AbstractExternalSource class AbstractExternalSource
# @return [String] the name of the Pod described by this external source. # @return [String] the name of the Pod described by this external source.
# #
attr_reader :name attr_reader :name
...@@ -48,14 +46,14 @@ module Pod ...@@ -48,14 +46,14 @@ module Pod
# #
# @return [void] # @return [void]
# #
def fetch(sandbox) def fetch(_sandbox)
raise "Abstract method" raise 'Abstract method'
end end
# @return [String] a string representation of the source suitable for UI. # @return [String] a string representation of the source suitable for UI.
# #
def description def description
raise "Abstract method" raise 'Abstract method'
end end
protected protected
...@@ -98,7 +96,7 @@ module Pod ...@@ -98,7 +96,7 @@ module Pod
# #
def pre_download(sandbox) def pre_download(sandbox)
title = "Pre-downloading: `#{name}` #{description}" title = "Pre-downloading: `#{name}` #{description}"
UI.titled_section(title, { :verbose_prefix => "-> " }) do UI.titled_section(title, :verbose_prefix => '-> ') do
target = sandbox.root + name target = sandbox.root + name
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(target, params) downloader = Downloader.for_target(target, params)
...@@ -137,4 +135,3 @@ module Pod ...@@ -137,4 +135,3 @@ module Pod
end end
end end
end end
module Pod module Pod
module ExternalSources module ExternalSources
# Provides support for fetching a specification file from a source handled # Provides support for fetching a specification file from a source handled
# by the downloader. Supports all the options of the downloader # by the downloader. Supports all the options of the downloader
# #
...@@ -8,7 +7,6 @@ module Pod ...@@ -8,7 +7,6 @@ module Pod
# name matching the one of the dependency. # name matching the one of the dependency.
# #
class DownloaderSource < AbstractExternalSource class DownloaderSource < AbstractExternalSource
# @see AbstractExternalSource#fetch # @see AbstractExternalSource#fetch
# #
def fetch(sandbox) def fetch(sandbox)
......
module Pod module Pod
module ExternalSources module ExternalSources
# Provides support for fetching a specification file from a path local to # Provides support for fetching a specification file from a path local to
# the machine running the installation. # the machine running the installation.
# #
# Works with the {LocalPod::LocalSourcedPod} class. # Works with the {LocalPod::LocalSourcedPod} class.
# #
class PathSource < AbstractExternalSource class PathSource < AbstractExternalSource
# @see AbstractExternalSource#fetch # @see AbstractExternalSource#fetch
# #
def fetch(sandbox) def fetch(sandbox)
title = "Fetching podspec for `#{name}` #{description}" title = "Fetching podspec for `#{name}` #{description}"
UI.titled_section(title, { :verbose_prefix => "-> " }) do UI.titled_section(title, :verbose_prefix => '-> ') do
podspec = podspec_path podspec = podspec_path
unless podspec.exist? unless podspec.exist?
raise Informative, "No podspec found for `#{name}` in " \ raise Informative, "No podspec found for `#{name}` in " \
...@@ -55,4 +53,3 @@ module Pod ...@@ -55,4 +53,3 @@ module Pod
end end
end end
end end
module Pod module Pod
module ExternalSources module ExternalSources
# Provides support for fetching a specification file from an URL. Can be # Provides support for fetching a specification file from an URL. Can be
# http, file, etc. # http, file, etc.
# #
class PodspecSource < AbstractExternalSource class PodspecSource < AbstractExternalSource
# @see AbstractExternalSource#fetch # @see AbstractExternalSource#fetch
# #
def fetch(sandbox) def fetch(sandbox)
title = "Fetching podspec for `#{name}` #{description}" title = "Fetching podspec for `#{name}` #{description}"
UI.titled_section(title, { :verbose_prefix => "-> " }) do UI.titled_section(title, :verbose_prefix => '-> ') do
is_json = podspec_uri.split('.').last == 'json' is_json = podspec_uri.split('.').last == 'json'
require 'open-uri' require 'open-uri'
open(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) } open(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) }
......
...@@ -3,4 +3,3 @@ module Pod ...@@ -3,4 +3,3 @@ module Pod
# #
VERSION = '0.33.1' unless defined? Pod::VERSION VERSION = '0.33.1' unless defined? Pod::VERSION
end end
module Pod module Pod
module Generator module Generator
class Acknowledgements class Acknowledgements
# @return [Array<Class>] The classes of the acknowledgements generator # @return [Array<Class>] The classes of the acknowledgements generator
# subclasses. # subclasses.
# #
...@@ -29,25 +27,25 @@ module Pod ...@@ -29,25 +27,25 @@ module Pod
# @return [String] The title of the acknowledgements file. # @return [String] The title of the acknowledgements file.
# #
def header_title def header_title
"Acknowledgements" 'Acknowledgements'
end end
# @return [String] A text to present before listing the acknowledgements. # @return [String] A text to present before listing the acknowledgements.
# #
def header_text def header_text
"This application makes use of the following third party libraries:" 'This application makes use of the following third party libraries:'
end end
# @return [String] The title of the foot notes. # @return [String] The title of the foot notes.
# #
def footnote_title def footnote_title
"" ''
end end
# @return [String] the foot notes. # @return [String] the foot notes.
# #
def footnote_text def footnote_text
"Generated by CocoaPods - http://cocoapods.org" 'Generated by CocoaPods - http://cocoapods.org'
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -60,7 +58,7 @@ module Pod ...@@ -60,7 +58,7 @@ module Pod
# acknowledgements should be generated. # acknowledgements should be generated.
# #
def specs def specs
file_accessors.map{ |accessor| accessor.spec.root }.uniq file_accessors.map { |accessor| accessor.spec.root }.uniq
end end
# Returns the text of the license for the given spec. # Returns the text of the license for the given spec.
...@@ -101,7 +99,6 @@ module Pod ...@@ -101,7 +99,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
module Generator module Generator
class Markdown < Acknowledgements class Markdown < Acknowledgements
def self.path_from_basepath(path) def self.path_from_basepath(path)
Pathname.new(path.dirname + "#{path.basename.to_s}.markdown") Pathname.new(path.dirname + "#{path.basename}.markdown")
end end
def save_as(path) def save_as(path)
file = File.new(path, "w") file = File.new(path, 'w')
file.write(licenses) file.write(licenses)
file.close file.close
end end
def title_from_string(string, level) def title_from_string(string, level)
if !string.empty? unless string.empty?
"#" * level << " #{string}" '#' * level << " #{string}"
end end
end end
...@@ -29,7 +27,7 @@ module Pod ...@@ -29,7 +27,7 @@ module Pod
licenses_string = "#{title_from_string(header_title, 1)}\n#{header_text}\n" licenses_string = "#{title_from_string(header_title, 1)}\n#{header_text}\n"
specs.each do |spec| specs.each do |spec|
if (license = string_for_spec(spec)) if (license = string_for_spec(spec))
license = license.force_encoding("UTF-8") if license.respond_to?(:force_encoding) license = license.force_encoding('UTF-8') if license.respond_to?(:force_encoding)
licenses_string += license licenses_string += license
end end
end end
......
module Pod module Pod
module Generator module Generator
class Plist < Acknowledgements class Plist < Acknowledgements
def self.path_from_basepath(path) def self.path_from_basepath(path)
Pathname.new(path.dirname + "#{path.basename.to_s}.plist") Pathname.new(path.dirname + "#{path.basename}.plist")
end end
def save_as(path) def save_as(path)
...@@ -15,12 +14,12 @@ module Pod ...@@ -15,12 +14,12 @@ module Pod
{ {
:Title => plist_title, :Title => plist_title,
:StringsTable => plist_title, :StringsTable => plist_title,
:PreferenceSpecifiers => licenses :PreferenceSpecifiers => licenses,
} }
end end
def plist_title def plist_title
"Acknowledgements" 'Acknowledgements'
end end
def licenses def licenses
...@@ -36,26 +35,26 @@ module Pod ...@@ -36,26 +35,26 @@ module Pod
def hash_for_spec(spec) def hash_for_spec(spec)
if (license = license_text(spec)) if (license = license_text(spec))
{ {
:Type => "PSGroupSpecifier", :Type => 'PSGroupSpecifier',
:Title => spec.name, :Title => spec.name,
:FooterText => license :FooterText => license,
} }
end end
end end
def header_hash def header_hash
{ {
:Type => "PSGroupSpecifier", :Type => 'PSGroupSpecifier',
:Title => header_title, :Title => header_title,
:FooterText => header_text :FooterText => header_text,
} }
end end
def footnote_hash def footnote_hash
{ {
:Type => "PSGroupSpecifier", :Type => 'PSGroupSpecifier',
:Title => footnote_title, :Title => footnote_title,
:FooterText => footnote_text :FooterText => footnote_text,
} }
end end
end end
......
...@@ -10,11 +10,11 @@ module Pod ...@@ -10,11 +10,11 @@ module Pod
def save_as(pathname) def save_as(pathname)
pathname.open('w') do |source| pathname.open('w') do |source|
source.puts "#import <Foundation/Foundation.h>" source.puts '#import <Foundation/Foundation.h>'
source.puts "@interface #{class_name} : NSObject" source.puts "@interface #{class_name} : NSObject"
source.puts "@end" source.puts '@end'
source.puts "@implementation #{class_name}" source.puts "@implementation #{class_name}"
source.puts "@end" source.puts '@end'
end end
end end
end end
......
...@@ -2,7 +2,6 @@ require 'active_support/core_ext/string/strip' ...@@ -2,7 +2,6 @@ require 'active_support/core_ext/string/strip'
module Pod module Pod
module Generator module Generator
# Generates a header which allows to inspect at compile time the installed # Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod. # pods and the installed specifications of a pod.
# #
...@@ -24,7 +23,6 @@ module Pod ...@@ -24,7 +23,6 @@ module Pod
# #endif # #endif
# #
class TargetEnvironmentHeader class TargetEnvironmentHeader
# @return [Hash{String => LocalPod}] the specifications installed for # @return [Hash{String => LocalPod}] the specifications installed for
# the target by build configuration name. # the target by build configuration name.
# #
...@@ -104,7 +102,7 @@ module Pod ...@@ -104,7 +102,7 @@ module Pod
# The name of the spec. # The name of the spec.
# #
def safe_spec_name(spec_name) def safe_spec_name(spec_name)
spec_name.gsub(/[^\w]/,'_') spec_name.gsub(/[^\w]/, '_')
end end
# @return [String] # @return [String]
...@@ -136,13 +134,13 @@ module Pod ...@@ -136,13 +134,13 @@ module Pod
def indent(string, indent_count) def indent(string, indent_count)
indent = ' ' * (indent_count * 2) indent = ' ' * (indent_count * 2)
lines = string.lines.map { |line| lines = string.lines.map do |line|
if line == "\n" if line == "\n"
line line
else else
"#{indent}#{line}" "#{indent}#{line}"
end end
} end
lines.join lines.join
end end
...@@ -169,7 +167,6 @@ module Pod ...@@ -169,7 +167,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
module Generator module Generator
# Generates Xcode configuration files. A configuration file is generated # Generates Xcode configuration files. A configuration file is generated
# for each Pod and for each Pod target definition. The aggregates the # for each Pod and for each Pod target definition. The aggregates the
# configurations of the Pods and define target specific settings. # configurations of the Pods and define target specific settings.
# #
module XCConfig module XCConfig
autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig/aggregate_xcconfig' autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig/aggregate_xcconfig'
autoload :PublicPodXCConfig, 'cocoapods/generator/xcconfig/public_pod_xcconfig' autoload :PublicPodXCConfig, 'cocoapods/generator/xcconfig/public_pod_xcconfig'
autoload :PrivatePodXCConfig, 'cocoapods/generator/xcconfig/private_pod_xcconfig' autoload :PrivatePodXCConfig, 'cocoapods/generator/xcconfig/private_pod_xcconfig'
autoload :XCConfigHelper, 'cocoapods/generator/xcconfig/xcconfig_helper' autoload :XCConfigHelper, 'cocoapods/generator/xcconfig/xcconfig_helper'
end end
end end
end end
module Pod module Pod
module Generator module Generator
module XCConfig module XCConfig
# Generates the xcconfigs for the aggregate targets.
# Generates the xcconfigs for the aggregate targets.
#
class AggregateXCConfig
# @return [Target] the target represented by this xcconfig.
# #
attr_reader :target class AggregateXCConfig
# @return [Target] the target represented by this xcconfig.
#
attr_reader :target
# @param [Target] target @see target # @param [Target] target @see target
# #
# @param [String] configuration_name # @param [String] configuration_name
# The name of the build configuration to generate this xcconfig # The name of the build configuration to generate this xcconfig
# for. # for.
# #
def initialize(target, configuration_name) def initialize(target, configuration_name)
@target = target @target = target
@configuration_name = configuration_name @configuration_name = configuration_name
end end
# @return [Xcodeproj::Config] The generated xcconfig. # @return [Xcodeproj::Config] The generated xcconfig.
# #
attr_reader :xcconfig attr_reader :xcconfig
# Generates and saves the xcconfig to the given path. # Generates and saves the xcconfig to the given path.
# #
# @param [Pathname] path # @param [Pathname] path
# the path where the prefix header should be stored. # the path where the prefix header should be stored.
# #
# @return [void] # @return [void]
# #
def save_as(path) def save_as(path)
generate.save_as(path) generate.save_as(path)
end end
# Generates the xcconfig. # Generates the xcconfig.
# #
# @note The xcconfig file for a Pods integration target includes the # @note The xcconfig file for a Pods integration target includes the
# namespaced xcconfig files for each spec target dependency. # namespaced xcconfig files for each spec target dependency.
# Each namespaced configuration value is merged into the Pod # Each namespaced configuration value is merged into the Pod
# xcconfig file. # xcconfig file.
# #
# @todo This doesn't include the specs xcconfigs anymore and now the # @todo This doesn't include the specs xcconfigs anymore and now the
# logic is duplicated. # logic is duplicated.
# #
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
header_search_path_flags = target.sandbox.public_headers.search_paths header_search_path_flags = target.sandbox.public_headers.search_paths
@xcconfig = Xcodeproj::Config.new({ @xcconfig = Xcodeproj::Config.new(
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target), 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths), 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem') 'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem')
}) )
target.pod_targets.each do |pod_target| target.pod_targets.each do |pod_target|
next unless pod_target.include_in_build_config?(@configuration_name) next unless pod_target.include_in_build_config?(@configuration_name)
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig) XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework| file_accessor.vendored_frameworks.each do |vendored_framework|
XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root) XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root)
end end
file_accessor.vendored_libraries.each do |vendored_library| file_accessor.vendored_libraries.each do |vendored_library|
XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root) XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root)
end
end end
# Add pod static lib to list of libraries that are to be linked with
# the user’s project.
@xcconfig.merge!('OTHER_LDFLAGS' => %(-l "#{pod_target.name}"))
end end
# Add pod static lib to list of libraries that are to be linked with # TODO Need to decide how we are going to ensure settings like these
# the user’s project. # are always excluded from the user's project.
#
# See https://github.com/CocoaPods/CocoaPods/issues/1216
@xcconfig.attributes.delete('USE_HEADERMAP')
@xcconfig.merge!({ @xcconfig
'OTHER_LDFLAGS' => %Q(-l "#{pod_target.name}")
})
end end
# TODO Need to decide how we are going to ensure settings like these #---------------------------------------------------------------------#
# are always excluded from the user's project.
#
# See https://github.com/CocoaPods/CocoaPods/issues/1216
@xcconfig.attributes.delete('USE_HEADERMAP')
@xcconfig
end end
#-----------------------------------------------------------------------#
end
end end
end end
end end
module Pod module Pod
module Generator module Generator
module XCConfig module XCConfig
# Generates the private xcconfigs for the pod targets.
# Generates the private xcconfigs for the pod targets.
#
# The private xcconfig file for a Pod target merges the configuration
# values of the public namespaced xcconfig with the default private
# configuration values required by CocoaPods.
#
class PrivatePodXCConfig
# @return [Target] the target represented by this xcconfig.
# #
attr_reader :target # The private xcconfig file for a Pod target merges the configuration
# values of the public namespaced xcconfig with the default private
# @return [Xcodeproj::Config] The public xcconfig which this one will # configuration values required by CocoaPods.
# use.
# #
attr_reader :public_xcconfig class PrivatePodXCConfig
# @return [Target] the target represented by this xcconfig.
#
attr_reader :target
# @param [Target] target @see target # @return [Xcodeproj::Config] The public xcconfig which this one will
# @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig # use.
# #
def initialize(target, public_xcconfig) attr_reader :public_xcconfig
@target = target
@public_xcconfig = public_xcconfig
end
# @return [Xcodeproj::Config] The generated xcconfig. # @param [Target] target @see target
# # @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig
attr_reader :xcconfig #
def initialize(target, public_xcconfig)
@target = target
@public_xcconfig = public_xcconfig
end
# Generates and saves the xcconfig to the given path. # @return [Xcodeproj::Config] The generated xcconfig.
# #
# @param [Pathname] path attr_reader :xcconfig
# the path where the prefix header should be stored.
#
# @return [void]
#
def save_as(path)
generate.save_as(path)
end
# Generates the xcconfig. # Generates and saves the xcconfig to the given path.
# #
# @return [Xcodeproj::Config] # @param [Pathname] path
# # the path where the prefix header should be stored.
def generate #
search_paths = target.build_headers.search_paths.concat(target.sandbox.public_headers.search_paths) # @return [void]
config = { #
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target), def save_as(path)
'PODS_ROOT' => '${SRCROOT}', generate.save_as(path)
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths), end
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, target.xcconfig_prefix) # Generates the xcconfig.
@xcconfig = Xcodeproj::Config.new(xcconfig_hash) #
@xcconfig.includes = [target.name] # @return [Xcodeproj::Config]
@xcconfig #
end def generate
search_paths = target.build_headers.search_paths.concat(target.sandbox.public_headers.search_paths)
config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
# 'USE_HEADERMAP' => 'NO'
}
private xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, target.xcconfig_prefix)
@xcconfig = Xcodeproj::Config.new(xcconfig_hash)
@xcconfig.includes = [target.name]
@xcconfig
end
#-----------------------------------------------------------------------# private
# !@group Private Helpers #-----------------------------------------------------------------------#
# Returns the hash representation of an xcconfig which inherit from the # !@group Private Helpers
# namespaced keys of a given one.
# # Returns the hash representation of an xcconfig which inherit from the
# @param [Hash] source_config # namespaced keys of a given one.
# The xcconfig whose keys need to be inherited. #
# # @param [Hash] source_config
# @param [Hash] destination_config # The xcconfig whose keys need to be inherited.
# The config which should inherit the source config keys. #
# # @param [Hash] destination_config
# @return [Hash] The inheriting xcconfig. # The config which should inherit the source config keys.
# #
def add_xcconfig_namespaced_keys(source_config, destination_config, prefix) # @return [Hash] The inheriting xcconfig.
result = destination_config.dup #
source_config.each do |key, value| def add_xcconfig_namespaced_keys(source_config, destination_config, prefix)
prefixed_key = prefix + conditional_less_key(key) result = destination_config.dup
current_value = destination_config[key] source_config.each do |key, _value|
if current_value prefixed_key = prefix + conditional_less_key(key)
result[key] = "#{current_value} ${#{prefixed_key}}" current_value = destination_config[key]
else if current_value
result[key] = "${#{prefixed_key}}" result[key] = "#{current_value} ${#{prefixed_key}}"
else
result[key] = "${#{prefixed_key}}"
end
end end
result
end end
result
end
# Strips the [*]-syntax from the given xcconfig key. # Strips the [*]-syntax from the given xcconfig key.
# #
# @param [String] key # @param [String] key
# The key to strip. # The key to strip.
# #
# @return [String] The stripped key. # @return [String] The stripped key.
# #
def conditional_less_key(key) def conditional_less_key(key)
brackets_index = key.index('[') brackets_index = key.index('[')
if brackets_index if brackets_index
key[0...brackets_index] key[0...brackets_index]
else else
key key
end
end end
end
#-----------------------------------------------------------------------#
end #-----------------------------------------------------------------------#
end
end end
end end
end end
module Pod module Pod
module Generator module Generator
module XCConfig module XCConfig
# Generates the public xcconfigs for the pod targets.
#
# The public xcconfig file for a Pod is completely namespaced to prevent
# configuration value collision with the build settings of other Pods. This
# xcconfig includes the standard podspec defined values including
# libraries, frameworks, weak frameworks and xcconfig overrides.
#
class PublicPodXCConfig
# @return [Target] the target represented by this xcconfig.
#
attr_reader :target
# @param [Target] target @see target
#
def initialize(target)
@target = target
end
# Generates the public xcconfigs for the pod targets. # @return [Xcodeproj::Config] The generated xcconfig.
# #
# The public xcconfig file for a Pod is completely namespaced to prevent attr_reader :xcconfig
# configuration value collision with the build settings of other Pods. This
# xcconfig includes the standard podspec defined values including # Generates and saves the xcconfig to the given path.
# libraries, frameworks, weak frameworks and xcconfig overrides. #
# # @param [Pathname] path
class PublicPodXCConfig # the path where the prefix header should be stored.
#
# @return [Target] the target represented by this xcconfig. # @return [void]
# #
attr_reader :target def save_as(path)
generate.save_as(path, target.xcconfig_prefix)
# @param [Target] target @see target end
#
def initialize(target)
@target = target
end
# @return [Xcodeproj::Config] The generated xcconfig.
#
attr_reader :xcconfig
# Generates and saves the xcconfig to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
#
# @return [void]
#
def save_as(path)
generate.save_as(path, target.xcconfig_prefix)
end
# Generates the xcconfig for the target. # Generates the xcconfig for the target.
# #
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
@xcconfig = Xcodeproj::Config.new @xcconfig = Xcodeproj::Config.new
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig) XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework| file_accessor.vendored_frameworks.each do |vendored_framework|
XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root) XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root)
end end
file_accessor.vendored_libraries.each do |vendored_library| file_accessor.vendored_libraries.each do |vendored_library|
XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root) XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root)
end
end end
@xcconfig
end end
@xcconfig
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end
end
end end
end end
end end
module Pod module Pod
module Generator module Generator
module XCConfig module XCConfig
# Stores the shared logic of the classes of the XCConfig module. # Stores the shared logic of the classes of the XCConfig module.
# #
module XCConfigHelper module XCConfigHelper
# Converts an array of strings to a single string where the each string # Converts an array of strings to a single string where the each string
# is surrounded by double quotes and separated by a space. Used to # is surrounded by double quotes and separated by a space. Used to
# represent strings in a xcconfig file. # represent strings in a xcconfig file.
...@@ -19,7 +17,7 @@ module Pod ...@@ -19,7 +17,7 @@ module Pod
# #
def self.quote(strings, prefix = nil) def self.quote(strings, prefix = nil)
prefix = "#{prefix} " if prefix prefix = "#{prefix} " if prefix
strings.sort.map { |s| %W|#{prefix}"#{s}"| }.join(" ") strings.sort.map { |s| %W( #{prefix}"#{s}" ) }.join(' ')
end end
# @return [String] the default linker flags. `-ObjC` is always included # @return [String] the default linker flags. `-ObjC` is always included
...@@ -28,7 +26,7 @@ module Pod ...@@ -28,7 +26,7 @@ module Pod
# #
def self.default_ld_flags(target) def self.default_ld_flags(target)
ld_flags = '-ObjC' ld_flags = '-ObjC'
if target.target_definition.podfile.set_arc_compatibility_flag? and if target.target_definition.podfile.set_arc_compatibility_flag? &&
target.spec_consumers.any? { |consumer| consumer.requires_arc? } target.spec_consumers.any? { |consumer| consumer.requires_arc? }
ld_flags << ' -fobjc-arc' ld_flags << ' -fobjc-arc'
end end
...@@ -62,11 +60,11 @@ module Pod ...@@ -62,11 +60,11 @@ module Pod
# The xcconfig to edit. # The xcconfig to edit.
# #
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root) def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root)
name = File.basename(framework_path, ".framework") name = File.basename(framework_path, '.framework')
dirname = '$(PODS_ROOT)/' + framework_path.dirname.relative_path_from(sandbox_root).to_s dirname = '$(PODS_ROOT)/' + framework_path.dirname.relative_path_from(sandbox_root).to_s
build_settings = { build_settings = {
'OTHER_LDFLAGS' => "-framework #{name}", 'OTHER_LDFLAGS' => "-framework #{name}",
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]) 'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
} }
xcconfig.merge!(build_settings) xcconfig.merge!(build_settings)
end end
...@@ -81,11 +79,11 @@ module Pod ...@@ -81,11 +79,11 @@ module Pod
# The xcconfig to edit. # The xcconfig to edit.
# #
def self.add_library_build_settings(library_path, xcconfig, sandbox_root) def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
name = File.basename(library_path, ".a").sub(/\Alib/, '') name = File.basename(library_path, '.a').sub(/\Alib/, '')
dirname = '$(PODS_ROOT)/' + library_path.dirname.relative_path_from(sandbox_root).to_s dirname = '$(PODS_ROOT)/' + library_path.dirname.relative_path_from(sandbox_root).to_s
build_settings = { build_settings = {
'OTHER_LDFLAGS' => "-l#{name}", 'OTHER_LDFLAGS' => "-l#{name}",
'LIBRARY_SEARCH_PATHS' => quote([dirname]) 'LIBRARY_SEARCH_PATHS' => quote([dirname]),
} }
xcconfig.merge!(build_settings) xcconfig.merge!(build_settings)
end end
...@@ -101,7 +99,7 @@ module Pod ...@@ -101,7 +99,7 @@ module Pod
# @return [void] # @return [void]
# #
def self.add_developers_frameworks_if_needed(xcconfig, platform) def self.add_developers_frameworks_if_needed(xcconfig, platform)
matched_frameworks = xcconfig.frameworks & ['XCTest', 'SenTestingKit'] matched_frameworks = xcconfig.frameworks & %w(XCTest SenTestingKit)
unless matched_frameworks.empty? unless matched_frameworks.empty?
search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= '' search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= ''
search_paths_to_add = [] search_paths_to_add = []
......
module Pod module Pod
class Podfile class Podfile
def config def config
UI.warn "Podfile#config is deprecated. The config is accessible from " \ UI.warn 'Podfile#config is deprecated. The config is accessible from ' \
"the parameter passed to the hooks" 'the parameter passed to the hooks'
Config.instance Config.instance
end end
end end
class Podfile::TargetDefinition class Podfile::TargetDefinition
def copy_resources_script_name def copy_resources_script_name
UI.warn "TargetDefinition#copy_resources_script_name is deprecated. " \ UI.warn 'TargetDefinition#copy_resources_script_name is deprecated. ' \
"The value is accessible directly from the representation of the " \ 'The value is accessible directly from the representation of the ' \
"library using the #copy_resources_script_path method." 'library using the #copy_resources_script_path method.'
Config.instance.sandbox.root + "#{label}-resources.sh" Config.instance.sandbox.root + "#{label}-resources.sh"
end end
end end
module Hooks module Hooks
# The installer representation to pass to the hooks. # The installer representation to pass to the hooks.
# #
class InstallerRepresentation class InstallerRepresentation
public public
# @!group Public Hooks API # @!group Public Hooks API
...@@ -79,15 +76,16 @@ module Pod ...@@ -79,15 +76,16 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
public public
# @!group Compatibility # @!group Compatibility
# #
# The following aliases provides compatibility with CP < 0.17 # The following aliases provides compatibility with CP < 0.17
alias :target_installers :libraries alias_method :target_installers, :libraries
alias :specs_by_target :specs_by_lib alias_method :specs_by_target, :specs_by_lib
alias :local_pods_by_target :pods_by_lib alias_method :local_pods_by_target, :pods_by_lib
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -126,9 +124,6 @@ module Pod ...@@ -126,9 +124,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
module Hooks module Hooks
class LibraryRepresentation class LibraryRepresentation
# Stores the information of the target installer # Stores the information of the target installer
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -27,11 +26,11 @@ module Pod ...@@ -27,11 +26,11 @@ module Pod
# @return [Pathname] The path of the prefix_header # @return [Pathname] The path of the prefix_header
# #
def prefix_header_path def prefix_header_path
UI.warn "LibraryRepresentation#prefix_header_path is deprecated. " \ UI.warn 'LibraryRepresentation#prefix_header_path is deprecated. ' \
"Use the specification `prefix_header_contents` attribute." 'Use the specification `prefix_header_contents` attribute.'
library.prefix_header_path library.prefix_header_path
end end
alias :prefix_header_filename :prefix_header_path alias_method :prefix_header_filename, :prefix_header_path
# @return [Pathname] The path of the script used to copy the resources. # @return [Pathname] The path of the script used to copy the resources.
# #
...@@ -83,13 +82,10 @@ module Pod ...@@ -83,13 +82,10 @@ module Pod
def initialize(sandbox, library) def initialize(sandbox, library)
@sandbox = sandbox @sandbox = sandbox
@library = library @library = library
raise "[BUG]" unless library.is_a?(AggregateTarget) raise '[BUG]' unless library.is_a?(AggregateTarget)
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Specification class Specification
def config def config
UI.warn "[#{name}] Specification#config is deprecated. The config is accessible from " \ UI.warn "[#{name}] Specification#config is deprecated. The config is accessible from " \
"the parameter passed to the hooks" 'the parameter passed to the hooks'
Config.instance Config.instance
end end
end end
module Hooks module Hooks
# Stores the information of the Installer for the hooks # Stores the information of the Installer for the hooks
# #
class PodRepresentation class PodRepresentation
# @return [String] # @return [String]
# #
attr_accessor :name attr_accessor :name
...@@ -68,7 +65,6 @@ module Pod ...@@ -68,7 +65,6 @@ module Pod
attr_reader :file_accessors attr_reader :file_accessors
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
# Provides support for the hook system of CocoaPods. The system is designed # Provides support for the hook system of CocoaPods. The system is designed
# especially for plugins. Interested clients can register to notifications by # especially for plugins. Interested clients can register to notifications by
# name. # name.
...@@ -16,7 +15,6 @@ module Pod ...@@ -16,7 +15,6 @@ module Pod
# #
module HooksManager module HooksManager
class << self class << self
# @return [Hash{Symbol => Proc}] The list of the blocks that are # @return [Hash{Symbol => Proc}] The list of the blocks that are
# registered for each notification name. # registered for each notification name.
# #
...@@ -34,8 +32,8 @@ module Pod ...@@ -34,8 +32,8 @@ module Pod
raise ArgumentError, 'Missing name' unless name raise ArgumentError, 'Missing name' unless name
raise ArgumentError, 'Missing block' unless block raise ArgumentError, 'Missing block' unless block
@registrations ||= Hash.new @registrations ||= {}
@registrations[name] ||= Array.new @registrations[name] ||= []
@registrations[name] << block @registrations[name] << block
end end
......
require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/inflections'
module Pod module Pod
# The Installer is responsible of taking a Podfile and transform it in the # The Installer is responsible of taking a Podfile and transform it in the
# Pods libraries. It also integrates the user project so the Pods # Pods libraries. It also integrates the user project so the Pods
# libraries can be used out of the box. # libraries can be used out of the box.
...@@ -29,7 +28,6 @@ module Pod ...@@ -29,7 +28,6 @@ module Pod
# source control. # source control.
# #
class Installer class Installer
autoload :Analyzer, 'cocoapods/installer/analyzer' autoload :Analyzer, 'cocoapods/installer/analyzer'
autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer' autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer'
autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer' autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer'
...@@ -95,7 +93,7 @@ module Pod ...@@ -95,7 +93,7 @@ module Pod
end end
def resolve_dependencies def resolve_dependencies
UI.section "Analyzing dependencies" do UI.section 'Analyzing dependencies' do
analyze analyze
validate_build_configurations validate_build_configurations
prepare_for_legacy_compatibility prepare_for_legacy_compatibility
...@@ -104,7 +102,7 @@ module Pod ...@@ -104,7 +102,7 @@ module Pod
end end
def download_dependencies def download_dependencies
UI.section "Downloading dependencies" do UI.section 'Downloading dependencies' do
create_file_accessors create_file_accessors
install_pod_sources install_pod_sources
run_pre_install_hooks run_pre_install_hooks
...@@ -113,7 +111,7 @@ module Pod ...@@ -113,7 +111,7 @@ module Pod
end end
def generate_pods_project def generate_pods_project
UI.section "Generating Pods project" do UI.section 'Generating Pods project' do
prepare_pods_project prepare_pods_project
install_file_references install_file_references
install_libraries install_libraries
...@@ -219,7 +217,7 @@ module Pod ...@@ -219,7 +217,7 @@ module Pod
end end
unless sandbox_state.deleted.empty? unless sandbox_state.deleted.empty?
title_options = { :verbose_prefix => "-> ".red } title_options = { :verbose_prefix => '-> '.red }
sandbox_state.deleted.each do |pod_name| sandbox_state.deleted.each do |pod_name|
UI.titled_section("Removing #{pod_name}".red, title_options) do UI.titled_section("Removing #{pod_name}".red, title_options) do
sandbox.clean_pod(pod_name) sandbox.clean_pod(pod_name)
...@@ -253,7 +251,7 @@ module Pod ...@@ -253,7 +251,7 @@ module Pod
def install_pod_sources def install_pod_sources
@installed_specs = [] @installed_specs = []
pods_to_install = sandbox_state.added | sandbox_state.changed pods_to_install = sandbox_state.added | sandbox_state.changed
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)
if sandbox_state.changed.include?(spec.name) && sandbox.manifest if sandbox_state.changed.include?(spec.name) && sandbox.manifest
...@@ -346,7 +344,7 @@ module Pod ...@@ -346,7 +344,7 @@ module Pod
# @todo Clean and modify the project if it exists. # @todo Clean and modify the project if it exists.
# #
def prepare_pods_project def prepare_pods_project
UI.message "- Creating Pods project" do UI.message '- Creating Pods project' do
@pods_project = Pod::Project.new(sandbox.project_path) @pods_project = Pod::Project.new(sandbox.project_path)
analysis_result.all_user_build_configurations.each do |name, type| analysis_result.all_user_build_configurations.each do |name, type|
...@@ -378,7 +376,6 @@ module Pod ...@@ -378,7 +376,6 @@ module Pod
end end
end end
# Installs the file references in the Pods project. This is done once per # Installs the file references in the Pods project. This is done once per
# Pod as the same file reference might be shared by multiple aggregate # Pod as the same file reference might be shared by multiple aggregate
# targets. # targets.
...@@ -396,7 +393,7 @@ module Pod ...@@ -396,7 +393,7 @@ module Pod
# @return [void] # @return [void]
# #
def install_libraries def install_libraries
UI.message"- Installing libraries" do UI.message'- Installing libraries' do
pod_targets.sort_by(&:name).each do |pod_target| pod_targets.sort_by(&:name).each do |pod_target|
next if pod_target.target_definition.empty? next if pod_target.target_definition.empty?
target_installer = PodTargetInstaller.new(sandbox, pod_target) target_installer = PodTargetInstaller.new(sandbox, pod_target)
...@@ -448,7 +445,7 @@ module Pod ...@@ -448,7 +445,7 @@ module Pod
UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do
pods_project.pods.remove_from_project if pods_project.pods.empty? pods_project.pods.remove_from_project if pods_project.pods.empty?
pods_project.development_pods.remove_from_project if pods_project.development_pods.empty? pods_project.development_pods.remove_from_project if pods_project.development_pods.empty?
pods_project.sort({:groups_position => :below}) pods_project.sort(:groups_position => :below)
pods_project.recreate_user_schemes(false) pods_project.recreate_user_schemes(false)
pods_project.save pods_project.save
end end
...@@ -504,9 +501,9 @@ module Pod ...@@ -504,9 +501,9 @@ module Pod
# @return [void] # @return [void]
# #
def run_pre_install_hooks def run_pre_install_hooks
UI.message "- Running pre install hooks" do UI.message '- Running pre install hooks' do
executed = run_podfile_pre_install_hook executed = run_podfile_pre_install_hook
UI.message "- Podfile" if executed UI.message '- Podfile' if executed
end end
end end
...@@ -519,8 +516,8 @@ module Pod ...@@ -519,8 +516,8 @@ module Pod
def run_podfile_pre_install_hook def run_podfile_pre_install_hook
podfile.pre_install!(installer_rep) podfile.pre_install!(installer_rep)
rescue => e rescue => e
raise Informative, "An error occurred while processing the pre-install " \ raise Informative, 'An error occurred while processing the pre-install ' \
"hook of the Podfile." \ 'hook of the Podfile.' \
"\n\n#{e.message}\n\n#{e.backtrace * "\n"}" "\n\n#{e.message}\n\n#{e.backtrace * "\n"}"
end end
...@@ -532,9 +529,9 @@ module Pod ...@@ -532,9 +529,9 @@ module Pod
# @return [void] # @return [void]
# #
def run_podfile_post_install_hooks def run_podfile_post_install_hooks
UI.message "- Running post install hooks" do UI.message '- Running post install hooks' do
executed = run_podfile_post_install_hook executed = run_podfile_post_install_hook
UI.message "- Podfile" if executed UI.message '- Podfile' if executed
end end
end end
...@@ -547,8 +544,8 @@ module Pod ...@@ -547,8 +544,8 @@ module Pod
def run_podfile_post_install_hook def run_podfile_post_install_hook
podfile.post_install!(installer_rep) podfile.post_install!(installer_rep)
rescue => e rescue => e
raise Informative, "An error occurred while processing the post-install " \ raise Informative, 'An error occurred while processing the post-install ' \
"hook of the Podfile." \ 'hook of the Podfile.' \
"\n\n#{e.message}\n\n#{e.backtrace * "\n"}" "\n\n#{e.message}\n\n#{e.backtrace * "\n"}"
end end
...@@ -635,6 +632,5 @@ module Pod ...@@ -635,6 +632,5 @@ module Pod
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
end end
module Pod module Pod
class Installer class Installer
# Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate # Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate
# the information relative to a CocoaPods installation. # the information relative to a CocoaPods installation.
# #
class Analyzer class Analyzer
include Config::Mixin include Config::Mixin
autoload :SandboxAnalyzer, 'cocoapods/installer/analyzer/sandbox_analyzer' autoload :SandboxAnalyzer, 'cocoapods/installer/analyzer/sandbox_analyzer'
...@@ -111,7 +109,7 @@ module Pod ...@@ -111,7 +109,7 @@ module Pod
:none :none
elsif update == true elsif update == true
:all :all
elsif update[:pods] != nil elsif !update[:pods].nil?
:selected :selected
end end
end end
...@@ -125,7 +123,7 @@ module Pod ...@@ -125,7 +123,7 @@ module Pod
# modification of the sandbox in the resolution process. # modification of the sandbox in the resolution process.
# #
attr_accessor :allow_pre_downloads attr_accessor :allow_pre_downloads
alias_method :allow_pre_downloads?, :allow_pre_downloads alias_method :allow_pre_downloads?, :allow_pre_downloads
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -149,7 +147,7 @@ module Pod ...@@ -149,7 +147,7 @@ module Pod
def generate_podfile_state def generate_podfile_state
if lockfile if lockfile
pods_state = nil pods_state = nil
UI.section "Finding Podfile changes" do UI.section 'Finding Podfile changes' do
pods_by_state = lockfile.detect_changes_with_podfile(podfile) pods_by_state = lockfile.detect_changes_with_podfile(podfile)
pods_by_state.dup.each do |state, full_names| pods_by_state.dup.each do |state, full_names|
pods_by_state[state] = full_names.map { |fn| Specification.root_name(fn) } pods_by_state[state] = full_names.map { |fn| Specification.root_name(fn) }
...@@ -212,15 +210,15 @@ module Pod ...@@ -212,15 +210,15 @@ module Pod
grouped_specs.each do |pod_specs| grouped_specs.each do |pod_specs|
pod_target = PodTarget.new(pod_specs, target_definition, sandbox) pod_target = PodTarget.new(pod_specs, target_definition, sandbox)
if config.integrate_targets? if config.integrate_targets?
pod_target.user_build_configurations = target.user_build_configurations pod_target.user_build_configurations = target.user_build_configurations
pod_target.archs = @archs_by_target_def[target_definition] pod_target.archs = @archs_by_target_def[target_definition]
else else
pod_target.user_build_configurations = {} pod_target.user_build_configurations = {}
if target_definition.platform.name == :osx if target_definition.platform.name == :osx
pod_target.archs = '$(ARCHS_STANDARD_64_BIT)' pod_target.archs = '$(ARCHS_STANDARD_64_BIT)'
end
end end
end
target.pod_targets << pod_target target.pod_targets << pod_target
end end
end end
...@@ -290,7 +288,7 @@ module Pod ...@@ -290,7 +288,7 @@ module Pod
end end
unless deps_to_fetch.empty? unless deps_to_fetch.empty?
UI.section "Fetching external sources" do UI.section 'Fetching external sources' do
deps_to_fetch.uniq.sort.each do |dependency| deps_to_fetch.uniq.sort.each do |dependency|
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file) source = ExternalSources.from_dependency(dependency, podfile.defined_in_file)
source.fetch(sandbox) source.fetch(sandbox)
...@@ -343,7 +341,7 @@ module Pod ...@@ -343,7 +341,7 @@ module Pod
# #
def generate_sandbox_state def generate_sandbox_state
sandbox_state = nil sandbox_state = nil
UI.section "Comparing resolved specification to the sandbox manifest" do UI.section 'Comparing resolved specification to the sandbox manifest' do
sandbox_analyzer = SandboxAnalyzer.new(sandbox, result.specifications, update_mode?, lockfile) sandbox_analyzer = SandboxAnalyzer.new(sandbox, result.specifications, update_mode?, lockfile)
sandbox_state = sandbox_analyzer.analyze sandbox_state = sandbox_analyzer.analyze
sandbox_state.print sandbox_state.print
...@@ -381,7 +379,7 @@ module Pod ...@@ -381,7 +379,7 @@ module Pod
path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj' path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj'
path = Pathname.new(path) path = Pathname.new(path)
unless path.exist? unless path.exist?
raise Informative, "Unable to find the Xcode project " \ raise Informative, 'Unable to find the Xcode project ' \
"`#{path}` for the target `#{target_definition.label}`." "`#{path}` for the target `#{target_definition.label}`."
end end
...@@ -390,7 +388,7 @@ module Pod ...@@ -390,7 +388,7 @@ module Pod
if xcodeprojs.size == 1 if xcodeprojs.size == 1
path = xcodeprojs.first path = xcodeprojs.first
else else
raise Informative, "Could not automatically select an Xcode project. " \ raise Informative, 'Could not automatically select an Xcode project. ' \
"Specify one in your Podfile like so:\n\n" \ "Specify one in your Podfile like so:\n\n" \
" xcodeproj 'path/to/Project.xcodeproj'\n" " xcodeproj 'path/to/Project.xcodeproj'\n"
end end
...@@ -417,12 +415,12 @@ module Pod ...@@ -417,12 +415,12 @@ module Pod
targets = native_targets(user_project).select { |t| link_with.include?(t.name) } targets = native_targets(user_project).select { |t| link_with.include?(t.name) }
raise Informative, "Unable to find the targets named `#{link_with.to_sentence}` to link with target definition `#{target_definition.name}`" if targets.empty? raise Informative, "Unable to find the targets named `#{link_with.to_sentence}` to link with target definition `#{target_definition.name}`" if targets.empty?
elsif target_definition.link_with_first_target? elsif target_definition.link_with_first_target?
targets = [ native_targets(user_project).first ].compact targets = [native_targets(user_project).first].compact
raise Informative, "Unable to find a target" if targets.empty? raise Informative, 'Unable to find a target' if targets.empty?
else else
target = native_targets(user_project).find { |t| t.name == target_definition.name.to_s } target = native_targets(user_project).find { |t| t.name == target_definition.name.to_s }
targets = [ target ].compact targets = [target].compact
raise Informative, "Unable to find a target named `#{target_definition.name.to_s}`" if targets.empty? raise Informative, "Unable to find a target named `#{target_definition.name}`" if targets.empty?
end end
targets targets
end end
...@@ -442,7 +440,7 @@ module Pod ...@@ -442,7 +440,7 @@ module Pod
# #
def compute_user_build_configurations(target_definition, user_targets) def compute_user_build_configurations(target_definition, user_targets)
if user_targets if user_targets
user_targets.map { |t| t.build_configurations.map(&:name) }.flatten.inject({}) do |hash, name| user_targets.map { |t| t.build_configurations.map(&:name) }.flatten.reduce({}) do |hash, name|
hash[name] = name == 'Debug' ? :debug : :release hash[name] = name == 'Debug' ? :debug : :release
hash hash
end.merge(target_definition.build_configurations || {}) end.merge(target_definition.build_configurations || {})
...@@ -466,7 +464,7 @@ module Pod ...@@ -466,7 +464,7 @@ module Pod
user_targets.each do |target| user_targets.each do |target|
name ||= target.platform_name name ||= target.platform_name
raise Informative, "Targets with different platforms" unless name == target.platform_name raise Informative, 'Targets with different platforms' unless name == target.platform_name
if !deployment_target || deployment_target > Version.new(target.deployment_target) if !deployment_target || deployment_target > Version.new(target.deployment_target)
deployment_target = Version.new(target.deployment_target) deployment_target = Version.new(target.deployment_target)
end end
...@@ -484,7 +482,7 @@ module Pod ...@@ -484,7 +482,7 @@ module Pod
# @todo Is assigning the platform to the target definition the best way # @todo Is assigning the platform to the target definition the best way
# to go? # to go?
# #
def compute_archs_for_target_definition(target_definition, user_targets) def compute_archs_for_target_definition(_target_definition, user_targets)
archs = [] archs = []
user_targets.each do |target| user_targets.each do |target|
target_archs = target.common_resolved_build_setting('ARCHS') target_archs = target.common_resolved_build_setting('ARCHS')
...@@ -515,7 +513,7 @@ module Pod ...@@ -515,7 +513,7 @@ module Pod
@archs_by_target_def[target_definition] = archs @archs_by_target_def[target_definition] = archs
else else
unless target_definition.platform unless target_definition.platform
raise Informative, "It is necessary to specify the platform in the Podfile if not integrating." raise Informative, 'It is necessary to specify the platform in the Podfile if not integrating.'
end end
end end
end end
...@@ -524,7 +522,6 @@ module Pod ...@@ -524,7 +522,6 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class AnalysisResult class AnalysisResult
# @return [SpecsState] the states of the Podfile specs. # @return [SpecsState] the states of the Podfile specs.
# #
attr_accessor :podfile_state attr_accessor :podfile_state
...@@ -555,7 +552,7 @@ module Pod ...@@ -555,7 +552,7 @@ module Pod
# its type (`:debug` or `:release`). # its type (`:debug` or `:release`).
# #
def all_user_build_configurations def all_user_build_configurations
targets.inject({}) do |result, target| targets.reduce({}) do |result, target|
result.merge(target.user_build_configurations) result.merge(target.user_build_configurations)
end end
end end
...@@ -572,7 +569,6 @@ module Pod ...@@ -572,7 +569,6 @@ module Pod
# subspecs are added instead of the name of the Pods. # subspecs are added instead of the name of the Pods.
# #
class SpecsState class SpecsState
# @param [Hash{Symbol=>String}] pods_by_state # @param [Hash{Symbol=>String}] pods_by_state
# The **root** name of the pods grouped by their state # The **root** name of the pods grouped by their state
# (`:added`, `:removed`, `:changed` or `:unchanged`). # (`:added`, `:removed`, `:changed` or `:unchanged`).
...@@ -612,10 +608,10 @@ module Pod ...@@ -612,10 +608,10 @@ module Pod
# @return [void] # @return [void]
# #
def print def print
added .sort.each { |pod| UI.message("A".green + " #{pod}", '', 2) } added .sort.each { |pod| UI.message('A'.green + " #{pod}", '', 2) }
deleted .sort.each { |pod| UI.message("R".red + " #{pod}", '', 2) } deleted .sort.each { |pod| UI.message('R'.red + " #{pod}", '', 2) }
changed .sort.each { |pod| UI.message("M".yellow + " #{pod}", '', 2) } changed .sort.each { |pod| UI.message('M'.yellow + " #{pod}", '', 2) }
unchanged.sort.each { |pod| UI.message("-" + " #{pod}", '', 2) } unchanged.sort.each { |pod| UI.message('-' + " #{pod}", '', 2) }
end end
# Adds the name of a Pod to the give state. # Adds the name of a Pod to the give state.
...@@ -631,10 +627,9 @@ module Pod ...@@ -631,10 +627,9 @@ module Pod
# @return [void] # @return [void]
# #
def add_name(name, state) def add_name(name, state)
raise "[Bug] Attempt to add subspec to the pods state" if name.include?('/') raise '[Bug] Attempt to add subspec to the pods state' if name.include?('/')
self.send(state) << name send(state) << name
end end
end end
end end
end end
......
module Pod module Pod
class Installer class Installer
class Analyzer class Analyzer
# Analyze the sandbox to detect which Pods should be removed, and which # Analyze the sandbox to detect which Pods should be removed, and which
# ones should be reinstalled. # ones should be reinstalled.
# #
...@@ -28,7 +27,6 @@ module Pod ...@@ -28,7 +27,6 @@ module Pod
# - If none of the above conditions match. # - If none of the above conditions match.
# #
class SandboxAnalyzer class SandboxAnalyzer
# @return [Sandbox] The sandbox to analyze. # @return [Sandbox] The sandbox to analyze.
# #
attr_reader :sandbox attr_reader :sandbox
...@@ -98,7 +96,7 @@ module Pod ...@@ -98,7 +96,7 @@ module Pod
return :added if pod_added?(pod) return :added if pod_added?(pod)
return :deleted if pod_deleted?(pod) return :deleted if pod_deleted?(pod)
return :changed if pod_changed?(pod) return :changed if pod_changed?(pod)
return :unchanged :unchanged
end end
# Returns whether the Pod with the given name should be installed. # Returns whether the Pod with the given name should be installed.
...@@ -112,8 +110,8 @@ module Pod ...@@ -112,8 +110,8 @@ module Pod
# #
def pod_added?(pod) def pod_added?(pod)
return true if resolved_pods.include?(pod) && !sandbox_pods.include?(pod) return true if resolved_pods.include?(pod) && !sandbox_pods.include?(pod)
return true if !folder_exist?(pod) return true unless folder_exist?(pod)
return false false
end end
# Returns whether the Pod with the given name should be removed from # Returns whether the Pod with the given name should be removed from
...@@ -126,7 +124,7 @@ module Pod ...@@ -126,7 +124,7 @@ module Pod
# #
def pod_deleted?(pod) def pod_deleted?(pod)
return true if !resolved_pods.include?(pod) && sandbox_pods.include?(pod) return true if !resolved_pods.include?(pod) && sandbox_pods.include?(pod)
return false false
end end
# Returns whether the Pod with the given name should be considered # Returns whether the Pod with the given name should be considered
...@@ -154,7 +152,7 @@ module Pod ...@@ -154,7 +152,7 @@ module Pod
if update_mode if update_mode
return true if sandbox.head_pod?(pod) return true if sandbox.head_pod?(pod)
end end
return false false
end end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
...@@ -254,7 +252,6 @@ module Pod ...@@ -254,7 +252,6 @@ module Pod
end end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
end end
end end
end end
......
module Pod module Pod
class Installer class Installer
# Controller class responsible of installing the file references of the # Controller class responsible of installing the file references of the
# specifications in the Pods project. # specifications in the Pods project.
# #
class FileReferencesInstaller class FileReferencesInstaller
# @return [Sandbox] The sandbox of the installation. # @return [Sandbox] The sandbox of the installation.
# #
attr_reader :sandbox attr_reader :sandbox
...@@ -68,7 +66,7 @@ module Pod ...@@ -68,7 +66,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_source_files_references def add_source_files_references
UI.message "- Adding source files to Pods project" do UI.message '- Adding source files to Pods project' do
add_file_accessors_paths_to_pods_group(:source_files) add_file_accessors_paths_to_pods_group(:source_files)
end end
end end
...@@ -78,7 +76,7 @@ module Pod ...@@ -78,7 +76,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_frameworks_bundles def add_frameworks_bundles
UI.message "- Adding frameworks to Pods project" do UI.message '- Adding frameworks to Pods project' do
add_file_accessors_paths_to_pods_group(:vendored_frameworks, :frameworks) add_file_accessors_paths_to_pods_group(:vendored_frameworks, :frameworks)
end end
end end
...@@ -88,7 +86,7 @@ module Pod ...@@ -88,7 +86,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_vendored_libraries def add_vendored_libraries
UI.message "- Adding libraries to Pods project" do UI.message '- Adding libraries to Pods project' do
add_file_accessors_paths_to_pods_group(:vendored_libraries, :frameworks) add_file_accessors_paths_to_pods_group(:vendored_libraries, :frameworks)
end end
end end
...@@ -101,7 +99,7 @@ module Pod ...@@ -101,7 +99,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources def add_resources
UI.message "- Adding resources to Pods project" do UI.message '- Adding resources to Pods project' do
add_file_accessors_paths_to_pods_group(:resources, :resources) add_file_accessors_paths_to_pods_group(:resources, :resources)
add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources) add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources)
end end
...@@ -112,7 +110,7 @@ module Pod ...@@ -112,7 +110,7 @@ module Pod
# @return [void] # @return [void]
# #
def link_headers def link_headers
UI.message "- Linking headers" do UI.message '- Linking headers' do
libraries.each do |library| libraries.each do |library|
library.file_accessors.each do |file_accessor| library.file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name) headers_sandbox = Pathname.new(file_accessor.spec.root.name)
...@@ -202,7 +200,6 @@ module Pod ...@@ -202,7 +200,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Installer class Installer
# Context object designed to be used with the HooksManager which describes # Context object designed to be used with the HooksManager which describes
# the context of the installer. # the context of the installer.
# #
class HooksContext class HooksContext
# @return [String] The path to the sandbox root (`Pods` directory). # @return [String] The path to the sandbox root (`Pods` directory).
# #
attr_accessor :sandbox_root attr_accessor :sandbox_root
...@@ -40,7 +38,6 @@ module Pod ...@@ -40,7 +38,6 @@ module Pod
# Pure data class which describes and umbrella target. # Pure data class which describes and umbrella target.
# #
class UmbrellaTargetDescription class UmbrellaTargetDescription
# @return [String] The path of the user project # @return [String] The path of the user project
# integrated by this target. # integrated by this target.
# #
......
...@@ -2,14 +2,12 @@ require 'active_support/core_ext/string/strip' ...@@ -2,14 +2,12 @@ require 'active_support/core_ext/string/strip'
module Pod module Pod
class Installer class Installer
# Controller class responsible of installing the activated specifications # Controller class responsible of installing the activated specifications
# of a single Pod. # of a single Pod.
# #
# @note This class needs to consider all the activated specs of a Pod. # @note This class needs to consider all the activated specs of a Pod.
# #
class PodSourceInstaller class PodSourceInstaller
# @return [Sandbox] # @return [Sandbox]
# #
attr_reader :sandbox attr_reader :sandbox
...@@ -62,7 +60,7 @@ module Pod ...@@ -62,7 +60,7 @@ module Pod
# @return [void] # @return [void]
# #
def clean! def clean!
clean_installation if !local? clean_installation unless local?
end end
# @return [Hash] # @return [Hash]
...@@ -89,9 +87,9 @@ module Pod ...@@ -89,9 +87,9 @@ module Pod
@specific_source = downloader.checkout_options @specific_source = downloader.checkout_options
rescue RuntimeError => e rescue RuntimeError => e
if e.message == 'Abstract method' if e.message == 'Abstract method'
raise Informative, "The pod '" + root_spec.name + "' does not " + raise Informative, "The pod '" + root_spec.name + "' does not " \
"support the :head option, as it uses a " + downloader.name + 'support the :head option, as it uses a ' + downloader.name +
" source. Remove that option to use this pod." ' source. Remove that option to use this pod.'
else else
raise raise
end end
...@@ -104,7 +102,7 @@ module Pod ...@@ -104,7 +102,7 @@ module Pod
end end
if specific_source if specific_source
sandbox.store_checkout_source(root_spec.name, specific_source) sandbox.store_checkout_source(root_spec.name, specific_source)
end end
end end
...@@ -121,7 +119,7 @@ module Pod ...@@ -121,7 +119,7 @@ module Pod
# #
def run_prepare_command def run_prepare_command
return unless root_spec.prepare_command return unless root_spec.prepare_command
UI.section(" > Running prepare command", '', 1) do UI.section(' > Running prepare command', '', 1) do
Dir.chdir(root) do Dir.chdir(root) do
ENV.delete('CDPATH') ENV.delete('CDPATH')
prepare_command = root_spec.prepare_command.strip_heredoc.chomp prepare_command = root_spec.prepare_command.strip_heredoc.chomp
...@@ -237,7 +235,7 @@ module Pod ...@@ -237,7 +235,7 @@ module Pod
def clean_paths def clean_paths
cached_used = used_files cached_used = used_files
glob_options = File::FNM_DOTMATCH | File::FNM_CASEFOLD glob_options = File::FNM_DOTMATCH | File::FNM_CASEFOLD
files = Pathname.glob(root + "**/*", glob_options).map(&:to_s) files = Pathname.glob(root + '**/*', glob_options).map(&:to_s)
files.reject! do |candidate| files.reject! do |candidate|
candidate = candidate.downcase candidate = candidate.downcase
...@@ -265,11 +263,10 @@ module Pod ...@@ -265,11 +263,10 @@ module Pod
file_accessors.map(&:source_files), file_accessors.map(&:source_files),
] ]
files.flatten.compact.map{ |path| path.to_s }.uniq files.flatten.compact.map { |path| path.to_s }.uniq
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
...@@ -6,13 +6,11 @@ require 'active_support/core_ext/array/conversions' ...@@ -6,13 +6,11 @@ require 'active_support/core_ext/array/conversions'
module Pod module Pod
class Installer class Installer
# The {UserProjectIntegrator} integrates the libraries generated by # The {UserProjectIntegrator} integrates the libraries generated by
# TargetDefinitions of the {Podfile} with their correspondent user # TargetDefinitions of the {Podfile} with their correspondent user
# projects. # projects.
# #
class UserProjectIntegrator class UserProjectIntegrator
autoload :TargetIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator' autoload :TargetIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator'
# @return [Podfile] the podfile that should be integrated with the user # @return [Podfile] the podfile that should be integrated with the user
...@@ -129,8 +127,8 @@ module Pod ...@@ -129,8 +127,8 @@ module Pod
# @return [void] # @return [void]
# #
def warn_about_empty_podfile def warn_about_empty_podfile
if podfile.target_definitions.values.all?{ |td| td.empty? } if podfile.target_definitions.values.all? { |td| td.empty? }
UI.warn "[!] The Podfile does not contain any dependencies." UI.warn '[!] The Podfile does not contain any dependencies.'
end end
end end
...@@ -175,7 +173,7 @@ module Pod ...@@ -175,7 +173,7 @@ module Pod
project = user_project_paths.first.basename('.xcodeproj') project = user_project_paths.first.basename('.xcodeproj')
installation_root + "#{project}.xcworkspace" installation_root + "#{project}.xcworkspace"
else else
raise Informative, "Could not automatically select an Xcode " \ raise Informative, 'Could not automatically select an Xcode ' \
"workspace. Specify one in your Podfile like so:\n\n" \ "workspace. Specify one in your Podfile like so:\n\n" \
" workspace 'path/to/Workspace.xcworkspace'\n" " workspace 'path/to/Workspace.xcworkspace'\n"
end end
...@@ -213,18 +211,17 @@ module Pod ...@@ -213,18 +211,17 @@ module Pod
# #
def print_override_warning(aggregate_target, user_target, config, key) def print_override_warning(aggregate_target, user_target, config, key)
actions = [ actions = [
"Use the `$(inherited)` flag, or", 'Use the `$(inherited)` flag, or',
"Remove the build settings from the target." 'Remove the build settings from the target.',
] ]
message = "The `#{user_target.name} [#{config.name}]` " \ message = "The `#{user_target.name} [#{config.name}]` " \
"target overrides the `#{key}` build setting defined in " \ "target overrides the `#{key}` build setting defined in " \
"`#{aggregate_target.xcconfig_relative_path(config.name)}'. " \ "`#{aggregate_target.xcconfig_relative_path(config.name)}'. " \
"This can lead to problems with the CocoaPods installation" 'This can lead to problems with the CocoaPods installation'
UI.warn(message, actions) UI.warn(message, actions)
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
...@@ -3,12 +3,10 @@ require 'active_support/core_ext/string/inflections' ...@@ -3,12 +3,10 @@ require 'active_support/core_ext/string/inflections'
module Pod module Pod
class Installer class Installer
class UserProjectIntegrator class UserProjectIntegrator
# This class is responsible for integrating the library generated by a # This class is responsible for integrating the library generated by a
# {TargetDefinition} with its destination project. # {TargetDefinition} with its destination project.
# #
class TargetIntegrator class TargetIntegrator
autoload :XCConfigIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator' autoload :XCConfigIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator'
# @return [Target] the target that should be integrated. # @return [Target] the target that should be integrated.
...@@ -45,7 +43,6 @@ module Pod ...@@ -45,7 +43,6 @@ module Pod
"#<#{self.class} for target `#{target.label}'>" "#<#{self.class} for target `#{target.label}'>"
end end
private private
# @!group Integration steps # @!group Integration steps
...@@ -64,7 +61,7 @@ module Pod ...@@ -64,7 +61,7 @@ module Pod
library = frameworks.files.select { |f| f.path == target.product_name }.first || library = frameworks.files.select { |f| f.path == target.product_name }.first ||
frameworks.new_product_ref_for_target(target.name, :static_library) frameworks.new_product_ref_for_target(target.name, :static_library)
unless native_target.frameworks_build_phase.files_references.include?(library) unless native_target.frameworks_build_phase.files_references.include?(library)
native_target.frameworks_build_phase.add_file_reference(library) native_target.frameworks_build_phase.add_file_reference(library)
end end
end end
end end
...@@ -76,12 +73,12 @@ module Pod ...@@ -76,12 +73,12 @@ module Pod
# @return [void] # @return [void]
# #
def add_copy_resources_script_phase def add_copy_resources_script_phase
phase_name = "Copy Pods Resources" phase_name = 'Copy Pods Resources'
native_targets_to_integrate.each do |native_target| native_targets_to_integrate.each do |native_target|
phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first || phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||
native_target.new_shell_script_build_phase(phase_name) native_target.new_shell_script_build_phase(phase_name)
path = target.copy_resources_script_relative_path path = target.copy_resources_script_relative_path
phase.shell_script = %{"#{path}"\n} phase.shell_script = %( "#{path}"\n )
phase.show_env_vars_in_log = '0' phase.show_env_vars_in_log = '0'
end end
end end
......
...@@ -71,7 +71,6 @@ module Pod ...@@ -71,7 +71,6 @@ module Pod
config.base_configuration_reference = file_ref config.base_configuration_reference = file_ref
end end
private private
# @!group Private helpers # @!group Private helpers
...@@ -94,13 +93,13 @@ module Pod ...@@ -94,13 +93,13 @@ module Pod
# #
def self.print_override_warning(pod_bundle, target, config, key) def self.print_override_warning(pod_bundle, target, config, key)
actions = [ actions = [
"Use the `$(inherited)` flag, or", 'Use the `$(inherited)` flag, or',
"Remove the build settings from the target." 'Remove the build settings from the target.',
] ]
message = "The `#{target.name} [#{config.name}]` " \ message = "The `#{target.name} [#{config.name}]` " \
"target overrides the `#{key}` build setting defined in " \ "target overrides the `#{key}` build setting defined in " \
"`#{pod_bundle.xcconfig_relative_path(config.name)}'. " \ "`#{pod_bundle.xcconfig_relative_path(config.name)}'. " \
"This can lead to problems with the CocoaPods installation" 'This can lead to problems with the CocoaPods installation'
UI.warn(message, actions) UI.warn(message, actions)
end end
end end
......
...@@ -3,7 +3,6 @@ require 'open-uri' ...@@ -3,7 +3,6 @@ require 'open-uri'
# Allow OpenURI to follow http to https redirects. # Allow OpenURI to follow http to https redirects.
# #
module OpenURI module OpenURI
# Whether {#open} should follow a redirect. # Whether {#open} should follow a redirect.
# #
# Inspiration from: https://gist.github.com/1271420 # Inspiration from: https://gist.github.com/1271420
...@@ -17,7 +16,7 @@ module OpenURI ...@@ -17,7 +16,7 @@ module OpenURI
# (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3) # (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3)
# However this is ad hoc. It should be extensible/configurable. # However this is ad hoc. It should be extensible/configurable.
# #
def OpenURI.redirectable?(uri1, uri2) def self.redirectable?(uri1, uri2)
uri1.scheme.downcase == uri2.scheme.downcase || uri1.scheme.downcase == uri2.scheme.downcase ||
(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme) (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme)
end end
......
require 'xcodeproj' require 'xcodeproj'
module Pod module Pod
# The Pods project. # The Pods project.
# #
# Model class which provides helpers for working with the Pods project # Model class which provides helpers for working with the Pods project
# through the installation process. # through the installation process.
# #
class Project < Xcodeproj::Project class Project < Xcodeproj::Project
# @param [Pathname, String] path @see path # @param [Pathname, String] path @see path
# @param [Bool] skip_initialization # @param [Bool] skip_initialization
# Wether the project should be initialized from scratch. # Wether the project should be initialized from scratch.
...@@ -34,7 +32,6 @@ module Pod ...@@ -34,7 +32,6 @@ module Pod
# #
attr_reader :development_pods attr_reader :development_pods
public public
# @!group Pod Groups # @!group Pod Groups
...@@ -58,7 +55,7 @@ module Pod ...@@ -58,7 +55,7 @@ module Pod
# @return [PBXGroup] The new group. # @return [PBXGroup] The new group.
# #
def add_pod_group(pod_name, path, development = false, absolute = false) def add_pod_group(pod_name, path, development = false, absolute = false)
raise "[BUG]" if pod_group(pod_name) raise '[BUG]' if pod_group(pod_name)
parent_group = development ? development_pods : pods parent_group = development ? development_pods : pods
source_tree = absolute ? :absolute : :group source_tree = absolute ? :absolute : :group
...@@ -236,6 +233,5 @@ module Pod ...@@ -236,6 +233,5 @@ module Pod
attr_reader :refs_by_absolute_path attr_reader :refs_by_absolute_path
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
end end
module Pod module Pod
# The resolver is responsible of generating a list of specifications grouped # The resolver is responsible of generating a list of specifications grouped
# by target for a given Podfile. # by target for a given Podfile.
# #
...@@ -15,7 +14,6 @@ module Pod ...@@ -15,7 +14,6 @@ module Pod
# #
# #
class Resolver class Resolver
# @return [Sandbox] the Sandbox used by the resolver to find external # @return [Sandbox] the Sandbox used by the resolver to find external
# dependencies. # dependencies.
# #
......
require 'fileutils' require 'fileutils'
module Pod module Pod
# The sandbox provides support for the directory that CocoaPods uses for an # The sandbox provides support for the directory that CocoaPods uses for an
# installation. In this directory the Pods projects, the support files and # installation. In this directory the Pods projects, the support files and
# the sources of the Pods are stored. # the sources of the Pods are stored.
...@@ -46,7 +45,6 @@ module Pod ...@@ -46,7 +45,6 @@ module Pod
# See #833 # See #833
# #
class Sandbox class Sandbox
autoload :FileAccessor, 'cocoapods/sandbox/file_accessor' autoload :FileAccessor, 'cocoapods/sandbox/file_accessor'
autoload :HeadersStore, 'cocoapods/sandbox/headers_store' autoload :HeadersStore, 'cocoapods/sandbox/headers_store'
autoload :PathList, 'cocoapods/sandbox/path_list' autoload :PathList, 'cocoapods/sandbox/path_list'
...@@ -64,7 +62,7 @@ module Pod ...@@ -64,7 +62,7 @@ module Pod
def initialize(root) def initialize(root)
FileUtils.mkdir_p(root) FileUtils.mkdir_p(root)
@root = Pathname.new(root).realpath @root = Pathname.new(root).realpath
@public_headers = HeadersStore.new(self, "Headers") @public_headers = HeadersStore.new(self, 'Headers')
@predownloaded_pods = [] @predownloaded_pods = []
@head_pods = [] @head_pods = []
@checkout_sources = {} @checkout_sources = {}
...@@ -120,13 +118,13 @@ module Pod ...@@ -120,13 +118,13 @@ module Pod
# @return [Pathname] the path of the manifest. # @return [Pathname] the path of the manifest.
# #
def manifest_path def manifest_path
root + "Manifest.lock" root + 'Manifest.lock'
end end
# @return [Pathname] the path of the Pods project. # @return [Pathname] the path of the Pods project.
# #
def project_path def project_path
root + "Pods.xcodeproj" root + 'Pods.xcodeproj'
end end
# Returns the path for the directory where to store the support files of # Returns the path for the directory where to store the support files of
...@@ -137,7 +135,7 @@ module Pod ...@@ -137,7 +135,7 @@ module Pod
# #
# @return [Pathname] the path of the support files. # @return [Pathname] the path of the support files.
# #
def library_support_files_dir(name) def library_support_files_dir(_name)
# root + "Target Support Files/#{name}" # root + "Target Support Files/#{name}"
root root
end end
...@@ -202,9 +200,9 @@ module Pod ...@@ -202,9 +200,9 @@ module Pod
# @todo Migrate old installations and store the for all the pods. # @todo Migrate old installations and store the for all the pods.
# Two folders should be created `External Sources` and `Podspecs`. # Two folders should be created `External Sources` and `Podspecs`.
# #
def specifications_dir(external_source = false) def specifications_dir(_external_source = false)
# root + "Specifications" # root + "Specifications"
root + "Local Podspecs" root + 'Local Podspecs'
end end
# Returns the path of the specification for the Pod with the # Returns the path of the specification for the Pod with the
...@@ -395,7 +393,5 @@ module Pod ...@@ -395,7 +393,5 @@ module Pod
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
end end
module Pod module Pod
class Sandbox class Sandbox
# Resolves the file patterns of a specification against its root directory, # Resolves the file patterns of a specification against its root directory,
# taking into account any exclude pattern and the default extensions to use # taking into account any exclude pattern and the default extensions to use
# for directories. # for directories.
...@@ -8,7 +7,6 @@ module Pod ...@@ -8,7 +7,6 @@ module Pod
# @note The FileAccessor always returns absolute paths. # @note The FileAccessor always returns absolute paths.
# #
class FileAccessor class FileAccessor
HEADER_EXTENSIONS = Xcodeproj::Constants::HEADER_FILES_EXTENSIONS HEADER_EXTENSIONS = Xcodeproj::Constants::HEADER_FILES_EXTENSIONS
# @return [Sandbox::PathList] the directory where the source of the Pod # @return [Sandbox::PathList] the directory where the source of the Pod
...@@ -33,7 +31,7 @@ module Pod ...@@ -33,7 +31,7 @@ module Pod
@spec_consumer = spec_consumer @spec_consumer = spec_consumer
unless @spec_consumer unless @spec_consumer
raise Informative, "Attempt to initialize File Accessor without a specification consumer." raise Informative, 'Attempt to initialize File Accessor without a specification consumer.'
end end
end end
...@@ -151,7 +149,7 @@ module Pod ...@@ -151,7 +149,7 @@ module Pod
# @return [Pathname] The path of the auto-detected README file. # @return [Pathname] The path of the auto-detected README file.
# #
def readme def readme
path_list.glob(%w[ readme{*,.*} ]).first path_list.glob(%w( readme{*,.*} )).first
end end
# @return [Pathname] The path of the license file as indicated in the # @return [Pathname] The path of the license file as indicated in the
...@@ -161,7 +159,7 @@ module Pod ...@@ -161,7 +159,7 @@ module Pod
if spec_consumer.spec.root.license[:file] if spec_consumer.spec.root.license[:file]
path_list.root + spec_consumer.spec.root.license[:file] path_list.root + spec_consumer.spec.root.license[:file]
else else
path_list.glob(%w[ licen{c,s}e{*,.*} ]).first path_list.glob(%w( licen{c,s}e{*,.*} )).first
end end
end end
...@@ -229,9 +227,6 @@ module Pod ...@@ -229,9 +227,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Sandbox class Sandbox
# Provides support for managing a header directory. It also keeps track of # Provides support for managing a header directory. It also keeps track of
# the header search paths. # the header search paths.
# #
class HeadersStore class HeadersStore
# @return [Pathname] the absolute path of this header directory. # @return [Pathname] the absolute path of this header directory.
# #
def root def root
...@@ -91,7 +89,6 @@ module Pod ...@@ -91,7 +89,6 @@ module Pod
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
class Sandbox class Sandbox
# The PathList class is designed to perform multiple glob matches against # The PathList class is designed to perform multiple glob matches against
# a given directory. Basically, it generates a list of all the children # a given directory. Basically, it generates a list of all the children
# paths and matches the globs patterns against them, resulting in just one # paths and matches the globs patterns against them, resulting in just one
...@@ -11,7 +10,6 @@ module Pod ...@@ -11,7 +10,6 @@ module Pod
# {#read_file_system} # {#read_file_system}
# #
class PathList class PathList
# @return [Pathname] The root of the list whose files and directories # @return [Pathname] The root of the list whose files and directories
# are used to perform the matching operations. # are used to perform the matching operations.
# #
...@@ -46,15 +44,15 @@ module Pod ...@@ -46,15 +44,15 @@ module Pod
unless root.exist? unless root.exist?
raise Informative, "Attempt to read non existent folder `#{root}`." raise Informative, "Attempt to read non existent folder `#{root}`."
end end
root_length = root.to_s.length+1 root_length = root.to_s.length + 1
escaped_root = escape_path_for_glob(root) escaped_root = escape_path_for_glob(root)
paths = Dir.glob(escaped_root + "**/*", File::FNM_DOTMATCH) paths = Dir.glob(escaped_root + '**/*', File::FNM_DOTMATCH)
absolute_dirs = paths.select { |path| File.directory?(path) } absolute_dirs = paths.select { |path| File.directory?(path) }
relative_dirs = absolute_dirs.map { |p| p[root_length..-1] } relative_dirs = absolute_dirs.map { |p| p[root_length..-1] }
absolute_paths = paths.reject { |p| p == "#{root}/." || p == "#{root}/.." } absolute_paths = paths.reject { |p| p == "#{root}/." || p == "#{root}/.." }
relative_paths = absolute_paths.map { |p| p[root_length..-1] } relative_paths = absolute_paths.map { |p| p[root_length..-1] }
@files = relative_paths - relative_dirs @files = relative_paths - relative_dirs
@dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/,'') }.reject { |d| d == '.' || d == '..' } .uniq @dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/, '') }.reject { |d| d == '.' || d == '..' } .uniq
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -67,7 +65,7 @@ module Pod ...@@ -67,7 +65,7 @@ module Pod
# paths. # paths.
# #
def glob(patterns, options = {}) def glob(patterns, options = {})
relative_glob(patterns, options).map {|p| root + p } relative_glob(patterns, options).map { |p| root + p }
end end
# @return [Array<Pathname>] The list of relative paths that are case # @return [Array<Pathname>] The list of relative paths that are case
...@@ -164,9 +162,9 @@ module Pod ...@@ -164,9 +162,9 @@ module Pod
end end
if values_by_set.empty? if values_by_set.empty?
[ pattern ] [pattern]
else else
patterns = [ pattern ] patterns = [pattern]
values_by_set.each do |set, values| values_by_set.each do |set, values|
patterns = patterns.map do |old_pattern| patterns = patterns.map do |old_pattern|
values.map do |value| values.map do |value|
...@@ -192,13 +190,12 @@ module Pod ...@@ -192,13 +190,12 @@ module Pod
result = path.to_s result = path.to_s
characters_to_escape = ['[', ']', '{', '}', '?', '*'] characters_to_escape = ['[', ']', '{', '}', '?', '*']
characters_to_escape.each do |character| characters_to_escape.each do |character|
result.gsub!(character, "\\#{character}" ) result.gsub!(character, "\\#{character}")
end end
Pathname.new(result) Pathname.new(result)
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
end end
module Pod module Pod
# Manages all the sources known to the running CocoaPods Instance. # Manages all the sources known to the running CocoaPods Instance.
# #
class SourcesManager class SourcesManager
class << self class << self
include Config::Mixin include Config::Mixin
# @return [Source::Aggregate] the aggregate of all the sources known to # @return [Source::Aggregate] the aggregate of all the sources known to
...@@ -78,7 +75,7 @@ module Pod ...@@ -78,7 +75,7 @@ module Pod
sets = aggregate.search_by_name(query, false) sets = aggregate.search_by_name(query, false)
end end
if sets.empty? if sets.empty?
extra = ", author, summary, or description" if full_text_search extra = ', author, summary, or description' if full_text_search
raise Informative, "Unable to find a pod with name#{extra}" \ raise Informative, "Unable to find a pod with name#{extra}" \
"matching `#{query}`" "matching `#{query}`"
end end
...@@ -155,13 +152,13 @@ module Pod ...@@ -155,13 +152,13 @@ module Pod
UI.section "Updating spec repo `#{source.name}`" do UI.section "Updating spec repo `#{source.name}`" do
Dir.chdir(source.data_provider.repo) do Dir.chdir(source.data_provider.repo) do
begin begin
output = git!("pull --ff-only") output = git!('pull --ff-only')
UI.puts output if show_output && !config.verbose? UI.puts output if show_output && !config.verbose?
rescue Informative => e rescue Informative => e
UI.warn "CocoaPods was not able to update the " \ UI.warn 'CocoaPods was not able to update the ' \
"`#{source.name}` repo. If this is an unexpected issue " \ "`#{source.name}` repo. If this is an unexpected issue " \
"and persists you can inspect it running " \ 'and persists you can inspect it running ' \
"`pod repo update --verbose`" '`pod repo update --verbose`'
end end
end end
check_version_information(source.data_provider.repo) check_version_information(source.data_provider.repo)
...@@ -196,10 +193,10 @@ module Pod ...@@ -196,10 +193,10 @@ module Pod
versions = version_information(dir) versions = version_information(dir)
unless repo_compatible?(dir) unless repo_compatible?(dir)
min, max = versions['min'], versions['max'] min, max = versions['min'], versions['max']
version_msg = ( min == max ) ? min : "#{min} - #{max}" version_msg = ( min == max) ? min : "#{min} - #{max}"
raise Informative, "The `#{dir.basename}` repo requires " \ raise Informative, "The `#{dir.basename}` repo requires " \
"CocoaPods #{version_msg} (currently using #{Pod::VERSION})\n".red + "CocoaPods #{version_msg} (currently using #{Pod::VERSION})\n".red +
"Update CocoaPods, or checkout the appropriate tag in the repo." 'Update CocoaPods, or checkout the appropriate tag in the repo.'
end end
needs_sudo = path_writable?(__FILE__) needs_sudo = path_writable?(__FILE__)
...@@ -330,4 +327,3 @@ module Pod ...@@ -330,4 +327,3 @@ module Pod
end end
end end
end end
module Pod module Pod
# Model class which describes a Pods target. # Model class which describes a Pods target.
# #
# The Target class stores and provides the information necessary for # The Target class stores and provides the information necessary for
...@@ -7,7 +6,6 @@ module Pod ...@@ -7,7 +6,6 @@ module Pod
# This class is used to represent both the targets and their libraries. # This class is used to represent both the targets and their libraries.
# #
class Target class Target
# @return [PBXNativeTarget] the target definition of the Podfile that # @return [PBXNativeTarget] the target definition of the Podfile that
# generated this target. # generated this target.
# #
...@@ -101,7 +99,7 @@ module Pod ...@@ -101,7 +99,7 @@ module Pod
# the information about the installed pods. # the information about the installed pods.
# #
def target_environment_header_path def target_environment_header_path
support_files_root + "#{target_definition.label.to_s}-environment.h" support_files_root + "#{target_definition.label}-environment.h"
end end
# @return [Pathname] the absolute path of the prefix header file. # @return [Pathname] the absolute path of the prefix header file.
...@@ -123,6 +121,5 @@ module Pod ...@@ -123,6 +121,5 @@ module Pod
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
end end
module Pod module Pod
# Stores the information relative to the target used to cluster the targets # Stores the information relative to the target used to cluster the targets
# of the single Pods. The client targets will then depend on this one. # of the single Pods. The client targets will then depend on this one.
# #
class AggregateTarget < Target class AggregateTarget < Target
# @param [TargetDefinition] target_definition @see target_definition # @param [TargetDefinition] target_definition @see target_definition
# @param [Sandbox] sandbox @see sandbox # @param [Sandbox] sandbox @see sandbox
# #
...@@ -53,7 +51,7 @@ module Pod ...@@ -53,7 +51,7 @@ module Pod
user_target_uuids.map do |uuid| user_target_uuids.map do |uuid|
native_target = project.objects_by_uuid[uuid] native_target = project.objects_by_uuid[uuid]
unless native_target unless native_target
raise Informative, "[Bug] Unable to find the target with " \ raise Informative, '[Bug] Unable to find the target with ' \
"the `#{uuid}` UUID for the `#{self}` integration library" "the `#{uuid}` UUID for the `#{self}` integration library"
end end
native_target native_target
...@@ -69,7 +67,6 @@ module Pod ...@@ -69,7 +67,6 @@ module Pod
# #
attr_reader :xcconfigs attr_reader :xcconfigs
# @return [Array<PodTarget>] The dependencies for this target. # @return [Array<PodTarget>] The dependencies for this target.
# #
attr_accessor :pod_targets attr_accessor :pod_targets
......
module Pod module Pod
# Stores the information relative to the target used to compile a single Pod. # Stores the information relative to the target used to compile a single Pod.
# A pod can have one or more activated spec/subspecs. # A pod can have one or more activated spec/subspecs.
# #
class PodTarget < Target class PodTarget < Target
# @return [Specification] the spec for the target. # @return [Specification] the spec for the target.
# #
attr_reader :specs attr_reader :specs
...@@ -21,14 +19,14 @@ module Pod ...@@ -21,14 +19,14 @@ module Pod
@specs = specs @specs = specs
@target_definition = target_definition @target_definition = target_definition
@sandbox = sandbox @sandbox = sandbox
@build_headers = Sandbox::HeadersStore.new(sandbox, "BuildHeaders") @build_headers = Sandbox::HeadersStore.new(sandbox, 'BuildHeaders')
@file_accessors = [] @file_accessors = []
end end
# @return [String] the label for the target. # @return [String] the label for the target.
# #
def label def label
"#{target_definition.label.to_s}-#{root_spec.name}" "#{target_definition.label}-#{root_spec.name}"
end end
# @return [Array<Sandbox::FileAccessor>] the file accessors for the # @return [Array<Sandbox::FileAccessor>] the file accessors for the
...@@ -82,8 +80,8 @@ module Pod ...@@ -82,8 +80,8 @@ module Pod
else else
raise Informative, "The subspecs of `#{pod_name}` are linked to " \ raise Informative, "The subspecs of `#{pod_name}` are linked to " \
"different build configurations for the `#{target_definition}` " \ "different build configurations for the `#{target_definition}` " \
"target. CocoaPods does not support subspecs across different " \ 'target. CocoaPods does not support subspecs across different ' \
"build configurations." 'build configurations.'
end end
end end
......
require 'cocoapods/user_interface/error_report' require 'cocoapods/user_interface/error_report'
module Pod module Pod
# Provides support for UI output. It provides support for nested sections of # Provides support for UI output. It provides support for nested sections of
# information and for a verbose mode. # information and for a verbose mode.
# #
module UserInterface module UserInterface
require 'colored' require 'colored'
@title_colors = %w|yellow green| @title_colors = %w( yellow green )
@title_level = 0 @title_level = 0
@indentation_level = 2 @indentation_level = 2
@treat_titles_as_messages = false @treat_titles_as_messages = false
@warnings = [] @warnings = []
class << self class << self
include Config::Mixin include Config::Mixin
attr_accessor :indentation_level attr_accessor :indentation_level
...@@ -27,7 +24,7 @@ module Pod ...@@ -27,7 +24,7 @@ module Pod
# terminal should be disabled. # terminal should be disabled.
# #
attr_accessor :disable_wrap attr_accessor :disable_wrap
alias_method :disable_wrap?, :disable_wrap alias_method :disable_wrap?, :disable_wrap
# Prints a title taking an optional verbose prefix and # Prints a title taking an optional verbose prefix and
# a relative indentation valid for the UI action in the passed # a relative indentation valid for the UI action in the passed
...@@ -78,7 +75,7 @@ module Pod ...@@ -78,7 +75,7 @@ module Pod
# A title opposed to a section is always visible # A title opposed to a section is always visible
# #
def title(title, verbose_prefix = '', relative_indentation = 2) def title(title, verbose_prefix = '', relative_indentation = 2)
if(@treat_titles_as_messages) if @treat_titles_as_messages
message(title, verbose_prefix) message(title, verbose_prefix)
else else
title = verbose_prefix + title if config.verbose? title = verbose_prefix + title if config.verbose?
...@@ -122,7 +119,7 @@ module Pod ...@@ -122,7 +119,7 @@ module Pod
# #
def info(message) def info(message)
indentation = config.verbose? ? self.indentation_level : 0 indentation = config.verbose? ? self.indentation_level : 0
indented = wrap_string(message, " " * indentation) indented = wrap_string(message, ' ' * indentation)
puts(indented) puts(indented)
self.indentation_level += 2 self.indentation_level += 2
...@@ -170,7 +167,7 @@ module Pod ...@@ -170,7 +167,7 @@ module Pod
colored_title = title.green colored_title = title.green
end end
title(colored_title, "", 1) do title(colored_title, '', 1) do
puts_indented pod.summary puts_indented pod.summary
puts_indented "pod '#{pod.name}', '~> #{pod.version}'" puts_indented "pod '#{pod.name}', '~> #{pod.version}'"
labeled('Homepage', pod.homepage) labeled('Homepage', pod.homepage)
...@@ -210,7 +207,7 @@ module Pod ...@@ -210,7 +207,7 @@ module Pod
# wrapping it to the terminal width if necessary. # wrapping it to the terminal width if necessary.
# #
def puts_indented(message = '') def puts_indented(message = '')
indented = wrap_string(message, " " * self.indentation_level) indented = wrap_string(message, ' ' * self.indentation_level)
puts(indented) puts(indented)
end end
...@@ -225,7 +222,7 @@ module Pod ...@@ -225,7 +222,7 @@ module Pod
next if warning[:verbose_only] && !config.verbose? next if warning[:verbose_only] && !config.verbose?
STDERR.puts("\n[!] #{warning[:message]}".yellow) STDERR.puts("\n[!] #{warning[:message]}".yellow)
warning[:actions].each do |action| warning[:actions].each do |action|
indented = wrap_string(action, " - ") indented = wrap_string(action, ' - ')
puts(indented) puts(indented)
end end
end end
...@@ -302,9 +299,7 @@ module Pod ...@@ -302,9 +299,7 @@ module Pod
# Redirects cocoapods-core UI. # Redirects cocoapods-core UI.
# #
module CoreUI module CoreUI
class << self class << self
def puts(message) def puts(message)
UI.puts message UI.puts message
end end
...@@ -316,14 +311,12 @@ module Pod ...@@ -316,14 +311,12 @@ module Pod
end end
end end
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
module Xcodeproj module Xcodeproj
# Redirects xcodeproj UI. # Redirects xcodeproj UI.
# #
module UserInterface module UserInterface
def self.puts(message) def self.puts(message)
::Pod::UI.puts message ::Pod::UI.puts message
end end
...@@ -331,7 +324,5 @@ module Xcodeproj ...@@ -331,7 +324,5 @@ module Xcodeproj
def self.warn(message) def self.warn(message)
::Pod::UI.warn message ::Pod::UI.warn message
end end
end end
end end
...@@ -8,7 +8,7 @@ module Pod ...@@ -8,7 +8,7 @@ module Pod
module ErrorReport module ErrorReport
class << self class << self
def report(exception) def report(exception)
return <<-EOS <<-EOS
#{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed} #{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
...@@ -75,7 +75,7 @@ EOS ...@@ -75,7 +75,7 @@ EOS
def error_from_podfile(error) def error_from_podfile(error)
if error.message =~ /Podfile:(\d*)/ if error.message =~ /Podfile:(\d*)/
"\nIt appears to have originated from your Podfile at line #{$1}.\n" "\nIt appears to have originated from your Podfile at line #{Regexp.last_match[1]}.\n"
end end
end end
...@@ -90,12 +90,12 @@ EOS ...@@ -90,12 +90,12 @@ EOS
end end
def host_information def host_information
product, version, build =`sw_vers`.strip.split("\n").map { |line| line.split(":").last.strip } product, version, build = `sw_vers`.strip.split("\n").map { |line| line.split(':').last.strip }
"#{product} #{version} (#{build})" "#{product} #{version} (#{build})"
end end
def xcode_information def xcode_information
version, build = `xcodebuild -version`.strip.split("\n").map { |line| line.split(" ").last } version, build = `xcodebuild -version`.strip.split("\n").map { |line| line.split(' ').last }
"#{version} (#{build})" "#{version} (#{build})"
end end
......
module Pod module Pod
# Validates a Specification. # Validates a Specification.
# #
# Extends the Linter from the Core to add additional which require the # Extends the Linter from the Core to add additional which require the
...@@ -10,7 +9,6 @@ module Pod ...@@ -10,7 +9,6 @@ module Pod
# it without integration and building the project with xcodebuild. # it without integration and building the project with xcodebuild.
# #
class Validator class Validator
include Config::Mixin include Config::Mixin
# @return [Specification::Linter] the linter instance from CocoaPods # @return [Specification::Linter] the linter instance from CocoaPods
...@@ -70,7 +68,7 @@ module Pod ...@@ -70,7 +68,7 @@ module Pod
perform_linting perform_linting
perform_extensive_analysis(a_spec) if a_spec && !quick perform_extensive_analysis(a_spec) if a_spec && !quick
UI.puts " -> ".send(result_color) << (a_spec ? a_spec.to_s : file.basename.to_s) UI.puts ' -> '.send(result_color) << (a_spec ? a_spec.to_s : file.basename.to_s)
print_results print_results
validated? validated?
end end
...@@ -82,25 +80,25 @@ module Pod ...@@ -82,25 +80,25 @@ module Pod
def print_results def print_results
results.each do |result| results.each do |result|
if result.platforms == [:ios] if result.platforms == [:ios]
platform_message = "[iOS] " platform_message = '[iOS] '
elsif result.platforms == [:osx] elsif result.platforms == [:osx]
platform_message = "[OSX] " platform_message = '[OSX] '
end end
subspecs_message = "" subspecs_message = ''
if result.is_a?(Result) if result.is_a?(Result)
subspecs = result.subspecs.uniq subspecs = result.subspecs.uniq
if subspecs.count > 2 if subspecs.count > 2
subspecs_message = "[" + subspecs[0..2].join(', ') + ", and more...] " subspecs_message = '[' + subspecs[0..2].join(', ') + ', and more...] '
elsif subspecs.count > 0 elsif subspecs.count > 0
subspecs_message = "[" + subspecs.join(',') + "] " subspecs_message = '[' + subspecs.join(',') + '] '
end end
end end
case result.type case result.type
when :error then type = "ERROR" when :error then type = 'ERROR'
when :warning then type = "WARN" when :warning then type = 'WARN'
when :note then type = "NOTE" when :note then type = 'NOTE'
else raise "#{result.type}" end else raise "#{result.type}" end
UI.puts " - #{type.ljust(5)} | #{platform_message}#{subspecs_message}#{result.message}" UI.puts " - #{type.ljust(5)} | #{platform_message}#{subspecs_message}#{result.message}"
end end
...@@ -109,7 +107,7 @@ module Pod ...@@ -109,7 +107,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# @!group Configuration #  @!group Configuration
# @return [Bool] whether the validation should skip the checks that # @return [Bool] whether the validation should skip the checks that
# requires the download of the library. # requires the download of the library.
...@@ -127,7 +125,9 @@ module Pod ...@@ -127,7 +125,9 @@ module Pod
# @note Uses the `:path` option of the Podfile. # @note Uses the `:path` option of the Podfile.
# #
attr_writer :local attr_writer :local
def local?; @local; end def local?
@local
end
# @return [Bool] Whether the validator should fail only on errors or also # @return [Bool] Whether the validator should fail only on errors or also
# on warnings. # on warnings.
...@@ -177,7 +177,7 @@ module Pod ...@@ -177,7 +177,7 @@ module Pod
# @return [Pathname] the temporary directory used by the linter. # @return [Pathname] the temporary directory used by the linter.
# #
def validation_dir def validation_dir
Pathname.new(File.join(Pathname.new('/tmp').realpath,'CocoaPods/Lint')) Pathname.new(File.join(Pathname.new('/tmp').realpath, 'CocoaPods/Lint'))
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -229,7 +229,7 @@ module Pod ...@@ -229,7 +229,7 @@ module Pod
# Performs validation of a URL # Performs validation of a URL
# #
def validate_url(url) def validate_url(url)
resp = Pod::HTTP::validate_url(url) resp = Pod::HTTP.validate_url(url)
if !resp if !resp
warning "There was a problem validating the URL #{url}." warning "There was a problem validating the URL #{url}."
...@@ -352,8 +352,8 @@ module Pod ...@@ -352,8 +352,8 @@ module Pod
end end
if consumer.spec.root? if consumer.spec.root?
unless file_accessor.license || spec.license && ( spec.license[:type] == 'Public Domain' || spec.license[:text] ) unless file_accessor.license || spec.license && ( spec.license[:type] == 'Public Domain' || spec.license[:text])
warning "Unable to find a license file" warning 'Unable to find a license file'
end end
end end
end end
...@@ -389,14 +389,12 @@ module Pod ...@@ -389,14 +389,12 @@ module Pod
# Specialized Result to support subspecs aggregation # Specialized Result to support subspecs aggregation
# #
class Result < Specification::Linter::Result class Result < Specification::Linter::Result
def initialize(type, message)
super(type, message)
@subspecs = []
end
def initialize(type, message) attr_reader :subspecs
super(type, message)
@subspecs = []
end
attr_reader :subspecs
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -417,7 +415,7 @@ module Pod ...@@ -417,7 +415,7 @@ module Pod
local = local? local = local?
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform(platform_name, deployment_target) platform(platform_name, deployment_target)
if (local) if local
pod name, :path => podspec.dirname.to_s pod name, :path => podspec.dirname.to_s
else else
pod name, :podspec => podspec.to_s pod name, :podspec => podspec.to_s
...@@ -445,8 +443,8 @@ module Pod ...@@ -445,8 +443,8 @@ module Pod
l.include?('note: ') && (l !~ /expanded from macro/) l.include?('note: ') && (l !~ /expanded from macro/)
end end
selected_lines.map do |l| selected_lines.map do |l|
new = l.gsub(/\/tmp\/CocoaPods\/Lint\/Pods\//,'') new = l.gsub(/\/tmp\/CocoaPods\/Lint\/Pods\//, '')
new.gsub!(/^ */,' ') new.gsub!(/^ */, ' ')
end end
end end
...@@ -459,6 +457,5 @@ module Pod ...@@ -459,6 +457,5 @@ module Pod
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe "Command::Help" do describe 'Command::Help' do
extend SpecHelper::Command extend SpecHelper::Command
it "invokes the right command with --help flag" do it 'invokes the right command with --help flag' do
command = command('help', 'repo', 'push') command = command('help', 'repo', 'push')
command.send(:help_command).should.be.instance_of Pod::Command::Repo::Push command.send(:help_command).should.be.instance_of Pod::Command::Repo::Push
lambda { command.run }.should.raise CLAide::Help lambda { command.run }.should.raise CLAide::Help
end end
it "raises help! if no other command is passed" do it 'raises help! if no other command is passed' do
lambda { command('help').run }.should.raise CLAide::Help lambda { command('help').run }.should.raise CLAide::Help
end end
it "shows the right usage" do it 'shows the right usage' do
args = [CLAide::Argument.new('COMMAND', false)] args = [CLAide::Argument.new('COMMAND', false)]
Pod::Command::Help.arguments.should.equal args Pod::Command::Help.arguments.should.equal args
end end
......
...@@ -3,19 +3,18 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,19 +3,18 @@ require File.expand_path('../../../spec_helper', __FILE__)
require 'xcodeproj' require 'xcodeproj'
module Pod module Pod
describe Command::Init do describe Command::Init do
it "complains if project does not exist" do it 'complains if project does not exist' do
lambda { run_command('init') }.should.raise Informative lambda { run_command('init') }.should.raise Informative
lambda { run_command('init', 'foo.xcodeproj') }.should.raise CLAide::Help lambda { run_command('init', 'foo.xcodeproj') }.should.raise CLAide::Help
end end
it "complains if wrong parameters" do it 'complains if wrong parameters' do
lambda { run_command('too', 'many') }.should.raise CLAide::Help lambda { run_command('too', 'many') }.should.raise CLAide::Help
end end
it "complains if more than one project exists and none is specified" do it 'complains if more than one project exists and none is specified' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'test2.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test2.xcodeproj').save
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
...@@ -23,7 +22,7 @@ module Pod ...@@ -23,7 +22,7 @@ module Pod
end end
end end
it "complains if a Podfile already exists" do it 'complains if a Podfile already exists' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
(Pathname.pwd + 'Podfile').open('w') { |f| f << "pod 'AFNetworking'" } (Pathname.pwd + 'Podfile').open('w') { |f| f << "pod 'AFNetworking'" }
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
...@@ -31,7 +30,7 @@ module Pod ...@@ -31,7 +30,7 @@ module Pod
end end
end end
it "creates a Podfile for a project in current directory" do it 'creates a Podfile for a project in current directory' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
run_command('init') run_command('init')
...@@ -39,7 +38,7 @@ module Pod ...@@ -39,7 +38,7 @@ module Pod
end end
end end
it "creates a Podfile for a specified project" do it 'creates a Podfile for a specified project' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
Xcodeproj::Project.new(temporary_directory + 'test2.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test2.xcodeproj').save
...@@ -49,23 +48,23 @@ module Pod ...@@ -49,23 +48,23 @@ module Pod
end end
end end
it "creates a Podfile with targets from the project" do it 'creates a Podfile with targets from the project' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj') project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj')
target1 = project.new_target(:application, "AppA", :ios) target1 = project.new_target(:application, 'AppA', :ios)
target2 = project.new_target(:application, "AppB", :ios) target2 = project.new_target(:application, 'AppB', :ios)
project.save project.save
run_command('init') run_command('init')
config.podfile.nil?.should == false config.podfile.nil?.should == false
config.podfile.target_definitions.length.should == project.targets.length + 1 config.podfile.target_definitions.length.should == project.targets.length + 1
config.podfile.target_definitions["AppA"].nil?.should == false config.podfile.target_definitions['AppA'].nil?.should == false
config.podfile.target_definitions["AppB"].nil?.should == false config.podfile.target_definitions['AppB'].nil?.should == false
end end
end end
it "includes default pods in a Podfile" do it 'includes default pods in a Podfile' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir' tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath tmp_templates_dir.mkpath
...@@ -76,15 +75,15 @@ module Pod ...@@ -76,15 +75,15 @@ module Pod
project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj') project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj')
project.new_target(:application, 'AppA', :ios) project.new_target(:application, 'AppA', :ios)
project.save project.save
run_command('init') run_command('init')
dependencies = config.podfile.target_definitions["AppA"].dependencies dependencies = config.podfile.target_definitions['AppA'].dependencies
dependencies.map(&:name).should == ["AFNetworking"] dependencies.map(&:name).should == ['AFNetworking']
end end
end end
it "includes default test pods in test targets in a Podfile" do it 'includes default test pods in test targets in a Podfile' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir' tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath tmp_templates_dir.mkpath
...@@ -93,17 +92,17 @@ module Pod ...@@ -93,17 +92,17 @@ module Pod
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" } open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj') project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj')
project.new_target(:application, "AppTests", :ios) project.new_target(:application, 'AppTests', :ios)
project.save project.save
run_command('init') run_command('init')
dependencies = config.podfile.target_definitions["AppTests"].dependencies dependencies = config.podfile.target_definitions['AppTests'].dependencies
dependencies.map(&:name).should == ["Kiwi"] dependencies.map(&:name).should == ['Kiwi']
end end
end end
it "does not include default test pods if there are no test targets" do it 'does not include default test pods if there are no test targets' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir' tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath tmp_templates_dir.mkpath
...@@ -112,7 +111,7 @@ module Pod ...@@ -112,7 +111,7 @@ module Pod
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" } open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj') project = Xcodeproj::Project.new(temporary_directory + 'test.xcodeproj')
project.new_target(:application, "App", :ios) project.new_target(:application, 'App', :ios)
project.save project.save
run_command('init') run_command('init')
...@@ -122,7 +121,7 @@ module Pod ...@@ -122,7 +121,7 @@ module Pod
end end
end end
it "saves xcode project file in Podfile if one was supplied" do it 'saves xcode project file in Podfile if one was supplied' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'test1.xcodeproj').save
Xcodeproj::Project.new(temporary_directory + 'Project.xcodeproj').save Xcodeproj::Project.new(temporary_directory + 'Project.xcodeproj').save
...@@ -141,7 +140,7 @@ module Pod ...@@ -141,7 +140,7 @@ module Pod
run_command('init') run_command('init')
target_definition = config.podfile.target_definitions.values.first target_definition = config.podfile.target_definitions.values.first
target_definition.user_project_path.should == nil target_definition.user_project_path.should.nil?
end end
end end
end end
......
...@@ -13,7 +13,7 @@ module Pod ...@@ -13,7 +13,7 @@ module Pod
describe Command::IPC::Spec do describe Command::IPC::Spec do
it "converts a podspec to JSON and prints it to STDOUT" do it 'converts a podspec to JSON and prints it to STDOUT' do
out = run_command('ipc', 'spec', fixture('banana-lib/BananaLib.podspec')) out = run_command('ipc', 'spec', fixture('banana-lib/BananaLib.podspec'))
out.should.match /"name":"BananaLib"/ out.should.match /"name":"BananaLib"/
out.should.match /"version":"1.0"/ out.should.match /"version":"1.0"/
...@@ -26,7 +26,7 @@ module Pod ...@@ -26,7 +26,7 @@ module Pod
describe Command::IPC::Podfile do describe Command::IPC::Podfile do
it "converts a Podfile to yaml and prints it to STDOUT" do it 'converts a Podfile to yaml and prints it to STDOUT' do
out = run_command('ipc', 'podfile', fixture('Podfile')) out = run_command('ipc', 'podfile', fixture('Podfile'))
out.should.include('---') out.should.include('---')
out.should.match /target_definitions:/ out.should.match /target_definitions:/
...@@ -40,7 +40,7 @@ module Pod ...@@ -40,7 +40,7 @@ module Pod
describe Command::IPC::List do describe Command::IPC::List do
it "prints a list of podspecs in the yaml format and prints it to STDOUT" do it 'prints a list of podspecs in the yaml format and prints it to STDOUT' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
set = Specification.new('BananaLib') set = Specification.new('BananaLib')
set.stubs(:specification).returns(spec) set.stubs(:specification).returns(spec)
...@@ -58,7 +58,7 @@ module Pod ...@@ -58,7 +58,7 @@ module Pod
describe Command::IPC::UpdateSearchIndex do describe Command::IPC::UpdateSearchIndex do
it "updates the search index and prints its path to STDOUT" do it 'updates the search index and prints its path to STDOUT' do
SourcesManager.expects(:updated_search_index) SourcesManager.expects(:updated_search_index)
out = run_command('ipc', 'update-search-index') out = run_command('ipc', 'update-search-index')
out.should.include(SourcesManager.search_index_path.to_s) out.should.include(SourcesManager.search_index_path.to_s)
...@@ -70,7 +70,7 @@ module Pod ...@@ -70,7 +70,7 @@ module Pod
describe Command::IPC::Repl do describe Command::IPC::Repl do
it "prints the version of CocoaPods as its first message" do it 'prints the version of CocoaPods as its first message' do
command = Command::IPC::Repl.new(CLAide::ARGV.new([])) command = Command::IPC::Repl.new(CLAide::ARGV.new([]))
command.stubs(:listen) command.stubs(:listen)
command.run command.run
...@@ -79,7 +79,7 @@ module Pod ...@@ -79,7 +79,7 @@ module Pod
out.should.match /version: '#{Pod::VERSION}'/ out.should.match /version: '#{Pod::VERSION}'/
end end
it "converts forwards the commands to the other ipc subcommands prints the result to STDOUT" do it 'converts forwards the commands to the other ipc subcommands prints the result to STDOUT' do
command = Command::IPC::Repl.new(CLAide::ARGV.new([])) command = Command::IPC::Repl.new(CLAide::ARGV.new([]))
command.execute_repl_command("podfile #{fixture('Podfile')}") command.execute_repl_command("podfile #{fixture('Podfile')}")
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Lib::Create do describe Command::Lib::Create do
before do before do
@sut = Command::Lib::Create @sut = Command::Lib::Create
end end
it "complains if wrong parameters" do it 'complains if wrong parameters' do
lambda { run_command('lib', 'create') }.should.raise CLAide::Help lambda { run_command('lib', 'create') }.should.raise CLAide::Help
end end
it "complains if pod name contains spaces" do it 'complains if pod name contains spaces' do
lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help
end end
it "complains if pod name begins with a period" do it 'complains if pod name begins with a period' do
lambda { run_command('lib', 'create', '.HiddenPod') }.should.raise CLAide::Help lambda { run_command('lib', 'create', '.HiddenPod') }.should.raise CLAide::Help
end end
it "should create a new dir for the newly created pod" do it 'should create a new dir for the newly created pod' do
@sut.any_instance.stubs(:configure_template) @sut.any_instance.stubs(:configure_template)
url = @sut::TEMPLATE_REPO url = @sut::TEMPLATE_REPO
@sut.any_instance.expects(:git!).with("clone '#{url}' TestPod").once @sut.any_instance.expects(:git!).with("clone '#{url}' TestPod").once
run_command('lib', 'create', 'TestPod') run_command('lib', 'create', 'TestPod')
end end
it "configures the template after cloning it passing the name of the Pod as the argument" do it 'configures the template after cloning it passing the name of the Pod as the argument' do
@sut.any_instance.stubs(:clone_template) @sut.any_instance.stubs(:clone_template)
dir = SpecHelper.temporary_directory + 'TestPod' dir = SpecHelper.temporary_directory + 'TestPod'
dir.mkpath dir.mkpath
File.stubs(:exists?).with("configure").returns(true) File.stubs(:exists?).with('configure').returns(true)
@sut.any_instance.expects(:system).with("./configure TestPod").once @sut.any_instance.expects(:system).with('./configure TestPod').once
run_command('lib', 'create', 'TestPod') run_command('lib', 'create', 'TestPod')
end end
it "should show link to new pod guide after creation" do it 'should show link to new pod guide after creation' do
@sut.any_instance.stubs(:clone_template) @sut.any_instance.stubs(:clone_template)
@sut.any_instance.stubs(:configure_template) @sut.any_instance.stubs(:configure_template)
output = run_command('lib', 'create', 'TestPod') output = run_command('lib', 'create', 'TestPod')
...@@ -47,13 +46,13 @@ module Pod ...@@ -47,13 +46,13 @@ module Pod
@sut.any_instance.stubs(:configure_template) @sut.any_instance.stubs(:configure_template)
end end
it "should use the given template URL" do it 'should use the given template URL' do
template_url = 'https://github.com/custom/template.git' template_url = 'https://github.com/custom/template.git'
@sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once @sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
sut = run_command('lib', 'create', 'TestPod', template_url) sut = run_command('lib', 'create', 'TestPod', template_url)
end end
it "should use the default URL if no template URL is given" do it 'should use the default URL if no template URL is given' do
template_url = 'https://github.com/CocoaPods/pod-template.git' template_url = 'https://github.com/CocoaPods/pod-template.git'
@sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once @sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
run_command('lib', 'create', 'TestPod') run_command('lib', 'create', 'TestPod')
...@@ -61,53 +60,53 @@ module Pod ...@@ -61,53 +60,53 @@ module Pod
end end
describe Command::Lib::Lint do describe Command::Lib::Lint do
it "lints the current working directory" do it 'lints the current working directory' do
Dir.chdir(fixture('integration/Reachability')) do Dir.chdir(fixture('integration/Reachability')) do
cmd = command('lib', 'lint', '--only-errors', '--quick') cmd = command('lib', 'lint', '--only-errors', '--quick')
cmd.run cmd.run
UI.output.should.include "passed validation" UI.output.should.include 'passed validation'
end end
end end
it "lints a single spec in the current working directory" do it 'lints a single spec in the current working directory' do
Dir.chdir(fixture('integration/Reachability')) do Dir.chdir(fixture('integration/Reachability')) do
cmd = command('lib', 'lint', 'Reachability.podspec', '--quick', '--only-errors') cmd = command('lib', 'lint', 'Reachability.podspec', '--quick', '--only-errors')
cmd.run cmd.run
UI.output.should.include "passed validation" UI.output.should.include 'passed validation'
end end
end end
it "fails to lint a broken spec file and cleans up" do it 'fails to lint a broken spec file and cleans up' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
open(temporary_directory + 'Broken.podspec', 'w') { |f| open(temporary_directory + 'Broken.podspec', 'w') do |f|
f << 'Pod::Spec.new do |spec|' f << 'Pod::Spec.new do |spec|'
f << "spec.name = 'Broken'" f << "spec.name = 'Broken'"
f << 'end' f << 'end'
}
Validator.any_instance.expects(:no_clean=).with(false)
Validator.any_instance.stubs(:perform_extensive_analysis)
should.raise Pod::Informative do
run_command('lib', 'lint', 'Broken.podspec')
end
UI.output.should.include "Missing required attribute"
end end
Validator.any_instance.expects(:no_clean=).with(false)
Validator.any_instance.stubs(:perform_extensive_analysis)
should.raise Pod::Informative do
run_command('lib', 'lint', 'Broken.podspec')
end
UI.output.should.include 'Missing required attribute'
end
end end
it "fails to lint a broken spec file and leaves lint directory" do it 'fails to lint a broken spec file and leaves lint directory' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
open(temporary_directory + 'Broken.podspec', 'w') { |f| open(temporary_directory + 'Broken.podspec', 'w') do |f|
f << 'Pod::Spec.new do |spec|' f << 'Pod::Spec.new do |spec|'
f << "spec.name = 'Broken'" f << "spec.name = 'Broken'"
f << 'end' f << 'end'
} end
Validator.any_instance.expects(:no_clean=).with(true) Validator.any_instance.expects(:no_clean=).with(true)
Validator.any_instance.stubs(:perform_extensive_analysis) Validator.any_instance.stubs(:perform_extensive_analysis)
should.raise Pod::Informative do should.raise Pod::Informative do
run_command('lib', 'lint', 'Broken.podspec', '--no-clean') run_command('lib', 'lint', 'Broken.podspec', '--no-clean')
end
UI.output.should.include "Missing required attribute"
UI.output.should.include "Pods project available at"
end end
UI.output.should.include 'Missing required attribute'
UI.output.should.include 'Pods project available at'
end
end end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe "Command::List" do describe 'Command::List' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
before do before do
...@@ -9,15 +9,15 @@ module Pod ...@@ -9,15 +9,15 @@ module Pod
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "presents the known pods" do it 'presents the known pods' do
out = run_command('list') out = run_command('list')
[ /BananaLib/, [/BananaLib/,
/JSONKit/, /JSONKit/,
/\d+ pods were found/ /\d+ pods were found/,
].each { |regex| out.should =~ regex } ].each { |regex| out.should =~ regex }
end end
it "returns the new pods" do it 'returns the new pods' do
sets = SourcesManager.all_sets sets = SourcesManager.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' } jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
dates = { dates = {
...@@ -29,14 +29,14 @@ module Pod ...@@ -29,14 +29,14 @@ module Pod
out.should.not.include('JSONKit') out.should.not.include('JSONKit')
end end
it "presents the known pods with versions" do it 'presents the known pods with versions' do
sets = SourcesManager.all_sets sets = SourcesManager.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' } jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
out = run_command('list') out = run_command('list')
[ /BananaLib 1.0/, [/BananaLib 1.0/,
/JSONKit #{jsonkit_set.versions.first}/, /JSONKit #{jsonkit_set.versions.first}/,
/\d+ pods were found/ /\d+ pods were found/,
].each { |regex| out.should =~ regex } ].each { |regex| out.should =~ regex }
end end
end end
......
...@@ -4,14 +4,14 @@ module Pod ...@@ -4,14 +4,14 @@ module Pod
describe Command::Outdated do describe Command::Outdated do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do it 'tells the user that no Podfile was found in the current working dir' do
exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
it "tells the user that no Lockfile was found in the current working dir" do it 'tells the user that no Lockfile was found in the current working dir' do
file = temporary_directory + 'Podfile' file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') } File.open(file, 'w') { |f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory" exception.message.should.include "No `Podfile.lock' found in the current working directory"
...@@ -45,4 +45,3 @@ module Pod ...@@ -45,4 +45,3 @@ module Pod
end end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Project do describe Command::Project do
it "tells the user that no Podfile or podspec was found in the current working dir" do it 'tells the user that no Podfile or podspec was found in the current working dir' do
Command::Install.new(CLAide::ARGV.new(['--no-repo-update'])) Command::Install.new(CLAide::ARGV.new(['--no-repo-update']))
config.skip_repo_update.should.be.true config.skip_repo_update.should.be.true
end end
...@@ -15,7 +14,7 @@ module Pod ...@@ -15,7 +14,7 @@ module Pod
describe Command::Install do describe Command::Install do
it "tells the user that no Podfile or podspec was found in the current working dir" do it 'tells the user that no Podfile or podspec was found in the current working dir' do
exception = lambda { run_command('install', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('install', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
...@@ -27,12 +26,12 @@ module Pod ...@@ -27,12 +26,12 @@ module Pod
describe Command::Update do describe Command::Update do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do it 'tells the user that no Podfile was found in the current working dir' do
exception = lambda { run_command('update','--no-repo-update') }.should.raise Informative exception = lambda { run_command('update', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
it "tells the user that no Lockfile was found in the current working dir" do it 'tells the user that no Lockfile was found in the current working dir' do
file = temporary_directory + 'Podfile' file = temporary_directory + 'Podfile'
File.open(file, 'w') do |f| File.open(file, 'w') do |f|
f.puts('platform :ios') f.puts('platform :ios')
...@@ -44,7 +43,7 @@ module Pod ...@@ -44,7 +43,7 @@ module Pod
end end
end end
describe "tells the user that the Pods cannot be updated unless they are installed" do describe 'tells the user that the Pods cannot be updated unless they are installed' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
before do before do
...@@ -59,32 +58,30 @@ module Pod ...@@ -59,32 +58,30 @@ module Pod
pod 'BananaLib', '1.0' pod 'BananaLib', '1.0'
end end
specs = [ specs = [
Specification.new do |s| Specification.new do |s|
s.name = 'BananaLib' s.name = 'BananaLib'
s.version = '1.0' s.version = '1.0'
end end,
] ]
Lockfile.generate(podfile, specs).write_to_disk(temporary_directory + 'Podfile.lock') Lockfile.generate(podfile, specs).write_to_disk(temporary_directory + 'Podfile.lock')
end end
it "for a single missing Pod" do it 'for a single missing Pod' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('update', 'Reachability', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('update', 'Reachability', '--no-repo-update') }.should.raise Informative
exception.message.should.include "Pod `Reachability` is not installed and cannot be updated" exception.message.should.include 'Pod `Reachability` is not installed and cannot be updated'
end end
end end
it "for multiple missing Pods" do it 'for multiple missing Pods' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('update', 'Reachability', 'BananaLib2', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('update', 'Reachability', 'BananaLib2', '--no-repo-update') }.should.raise Informative
exception.message.should.include "Pods `Reachability`, `BananaLib2` are not installed and cannot be updated" exception.message.should.include 'Pods `Reachability`, `BananaLib2` are not installed and cannot be updated'
end end
end end
end end
end end
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
end end
...@@ -29,7 +29,7 @@ module Pod ...@@ -29,7 +29,7 @@ module Pod
repo_make('test_repo') repo_make('test_repo')
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
spec = "Spec.new do |s|; s.name = 'Broken'; s.version = '1.0' end" spec = "Spec.new do |s|; s.name = 'Broken'; s.version = '1.0' end"
File.open('Broken.podspec', 'w') {|f| f.write(spec) } File.open('Broken.podspec', 'w') { |f| f.write(spec) }
cmd = command('repo', 'push', 'test_repo') cmd = command('repo', 'push', 'test_repo')
Validator.any_instance.stubs(:validated?).returns(false) Validator.any_instance.stubs(:validated?).returns(false)
...@@ -60,12 +60,12 @@ module Pod ...@@ -60,12 +60,12 @@ module Pod
spec_clean = (fixture('spec-repos') + 'test_repo/BananaLib/1.0/BananaLib.podspec').read spec_clean = (fixture('spec-repos') + 'test_repo/BananaLib/1.0/BananaLib.podspec').read
File.open(temporary_directory + 'JSONKit.podspec', 'w') {|f| f.write(spec_fix) } File.open(temporary_directory + 'JSONKit.podspec', 'w') { |f| f.write(spec_fix) }
File.open(temporary_directory + 'PushTest.podspec', 'w') {|f| f.write(spec_add) } File.open(temporary_directory + 'PushTest.podspec', 'w') { |f| f.write(spec_add) }
File.open(temporary_directory + 'BananaLib.podspec', 'w') {|f| f.write(spec_clean) } File.open(temporary_directory + 'BananaLib.podspec', 'w') { |f| f.write(spec_clean) }
end end
it "refuses to push if the repo is not clean" do it 'refuses to push if the repo is not clean' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`git remote set-url origin https://github.com/CocoaPods/Specs.git` `git remote set-url origin https://github.com/CocoaPods/Specs.git`
end end
...@@ -74,7 +74,7 @@ module Pod ...@@ -74,7 +74,7 @@ module Pod
e.message.should.match(/use the `pod trunk push` command/) e.message.should.match(/use the `pod trunk push` command/)
end end
it "refuses to push if the repo is not clean" do it 'refuses to push if the repo is not clean' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`touch DIRTY_FILE` `touch DIRTY_FILE`
end end
...@@ -85,7 +85,7 @@ module Pod ...@@ -85,7 +85,7 @@ module Pod
(@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist? (@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist?
end end
it "successfully pushes a spec" do it 'successfully pushes a spec' do
cmd = command('repo', 'push', 'master') cmd = command('repo', 'push', 'master')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` } Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
......
...@@ -11,7 +11,7 @@ module Pod ...@@ -11,7 +11,7 @@ module Pod
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "updates a repository" do it 'updates a repository' do
upstream = SpecHelper.temporary_directory + 'upstream' upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream) FileUtils.cp_r(test_repo_path, upstream)
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
...@@ -23,11 +23,11 @@ module Pod ...@@ -23,11 +23,11 @@ module Pod
lambda { command('repo', 'update').run }.should.not.raise lambda { command('repo', 'update').run }.should.not.raise
end end
it "updates a spec-repo" do it 'updates a spec-repo' do
repo1 = repo_make('repo1') repo1 = repo_make('repo1')
repo2 = repo_clone('repo1', 'repo2') repo2 = repo_clone('repo1', 'repo2')
repo_make_readme_change(repo1, 'Updated') repo_make_readme_change(repo1, 'Updated')
Dir.chdir(repo1) {`git commit -a -m "Update"`} Dir.chdir(repo1) { `git commit -a -m "Update"` }
run_command('repo', 'update', 'repo2') run_command('repo', 'update', 'repo2')
(repo2 + 'README').read.should.include 'Updated' (repo2 + 'README').read.should.include 'Updated'
end end
...@@ -44,7 +44,7 @@ module Pod ...@@ -44,7 +44,7 @@ module Pod
::REST.stubs(:head => stub(:success? => true)) ::REST.stubs(:head => stub(:success? => true))
end end
it "lints a repository" do it 'lints a repository' do
repo = fixture('spec-repos/test_repo').to_s repo = fixture('spec-repos/test_repo').to_s
lambda { run_command('repo', 'lint', repo) }.should.not.raise lambda { run_command('repo', 'lint', repo) }.should.not.raise
end end
...@@ -59,25 +59,25 @@ module Pod ...@@ -59,25 +59,25 @@ module Pod
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "adds a spec-repo" do it 'adds a spec-repo' do
run_command('repo', 'add', 'private', test_repo_path) run_command('repo', 'add', 'private', test_repo_path)
Dir.chdir(config.repos_dir + 'private') do Dir.chdir(config.repos_dir + 'private') do
`git config --get remote.origin.url`.chomp.should == test_repo_path.to_s `git config --get remote.origin.url`.chomp.should == test_repo_path.to_s
end end
end end
it "adds a spec-repo with a specified branch" do it 'adds a spec-repo with a specified branch' do
repo1 = repo_make('repo1') repo1 = repo_make('repo1')
Dir.chdir(repo1) do Dir.chdir(repo1) do
`git checkout -b my-branch >/dev/null 2>&1` `git checkout -b my-branch >/dev/null 2>&1`
`git checkout master >/dev/null 2>&1` `git checkout master >/dev/null 2>&1`
end end
repo2 = command( 'repo' ,'add', 'repo2', repo1.to_s, 'my-branch') repo2 = command('repo', 'add', 'repo2', repo1.to_s, 'my-branch')
repo2.run repo2.run
Dir.chdir(repo2.dir) { `git symbolic-ref HEAD` }.should.include? 'my-branch' Dir.chdir(repo2.dir) { `git symbolic-ref HEAD` }.should.include? 'my-branch'
end end
it "adds a spec-repo by creating a shallow clone" do it 'adds a spec-repo by creating a shallow clone' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`echo 'touch' > touch && git add touch && git commit -m 'updated'` `echo 'touch' > touch && git add touch && git commit -m 'updated'`
end end
...@@ -98,7 +98,7 @@ module Pod ...@@ -98,7 +98,7 @@ module Pod
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "complains when a repository name is missing" do it 'complains when a repository name is missing' do
lambda { run_command('repo', 'remove') }.should.raise CLAide::Help lambda { run_command('repo', 'remove') }.should.raise CLAide::Help
end end
...@@ -106,7 +106,7 @@ module Pod ...@@ -106,7 +106,7 @@ module Pod
lambda { run_command('repo', 'remove', 'nonexistant') }.should.raise CLAide::Help lambda { run_command('repo', 'remove', 'nonexistant') }.should.raise CLAide::Help
end end
it "complains if we do not have permission" do it 'complains if we do not have permission' do
File.stubs(:writable?).returns(false) File.stubs(:writable?).returns(false)
upstream = SpecHelper.temporary_directory + 'upstream' upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream) FileUtils.cp_r(test_repo_path, upstream)
...@@ -114,7 +114,7 @@ module Pod ...@@ -114,7 +114,7 @@ module Pod
FileUtils.rm_rf(upstream) FileUtils.rm_rf(upstream)
end end
it "removes a spec-repo" do it 'removes a spec-repo' do
upstream = SpecHelper.temporary_directory + 'upstream' upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream) FileUtils.cp_r(test_repo_path, upstream)
lambda { run_command('repo', 'remove', upstream) }.should.not.raise lambda { run_command('repo', 'remove', upstream) }.should.not.raise
......
...@@ -11,28 +11,28 @@ module Pod ...@@ -11,28 +11,28 @@ module Pod
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
end end
it "runs with correct parameters" do it 'runs with correct parameters' do
lambda { run_command('search', 'JSON') }.should.not.raise lambda { run_command('search', 'JSON') }.should.not.raise
lambda { run_command('search', 'JSON', '--full') }.should.not.raise lambda { run_command('search', 'JSON', '--full') }.should.not.raise
end end
it "complains for wrong parameters" do it 'complains for wrong parameters' do
lambda { run_command('search') }.should.raise CLAide::Help lambda { run_command('search') }.should.raise CLAide::Help
lambda { run_command('search', 'too', '--wrong') }.should.raise CLAide::Help lambda { run_command('search', 'too', '--wrong') }.should.raise CLAide::Help
lambda { run_command('search', '--wrong') }.should.raise CLAide::Help lambda { run_command('search', '--wrong') }.should.raise CLAide::Help
end end
it "searches for a pod with name matching the given query ignoring case" do it 'searches for a pod with name matching the given query ignoring case' do
output = run_command('search', 'json') output = run_command('search', 'json')
output.should.include? 'JSONKit' output.should.include? 'JSONKit'
end end
it "searches for a pod with name, summary, or description matching the given query ignoring case" do it 'searches for a pod with name, summary, or description matching the given query ignoring case' do
output = run_command('search', 'Engelhart', '--full') output = run_command('search', 'Engelhart', '--full')
output.should.include? 'JSONKit' output.should.include? 'JSONKit'
end end
it "restricts the search to Pods supported on iOS" do it 'restricts the search to Pods supported on iOS' do
output = run_command('search', 'BananaLib', '--ios') output = run_command('search', 'BananaLib', '--ios')
output.should.include? 'BananaLib' output.should.include? 'BananaLib'
Specification.any_instance.stubs(:available_platforms).returns([Platform.osx]) Specification.any_instance.stubs(:available_platforms).returns([Platform.osx])
...@@ -40,50 +40,50 @@ module Pod ...@@ -40,50 +40,50 @@ module Pod
output.should.not.include? 'BananaLib' output.should.not.include? 'BananaLib'
end end
it "restricts the search to Pods supported on iOS" do it 'restricts the search to Pods supported on iOS' do
output = run_command('search', 'BananaLib', '--osx') output = run_command('search', 'BananaLib', '--osx')
output.should.not.include? 'BananaLib' output.should.not.include? 'BananaLib'
end end
it "outputs with the silent parameter" do it 'outputs with the silent parameter' do
output = run_command('search', 'BananaLib', '--silent') output = run_command('search', 'BananaLib', '--silent')
output.should.include? 'BananaLib' output.should.include? 'BananaLib'
end end
it "shows a friendly message when locally searching with invalid regex" do it 'shows a friendly message when locally searching with invalid regex' do
lambda { run_command('search', '+') }.should.raise CLAide::Help lambda { run_command('search', '+') }.should.raise CLAide::Help
end end
describe "option --web" do describe 'option --web' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "searches with invalid regex" do it 'searches with invalid regex' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat')
run_command('search', '--web', 'NSAttributedString+CCLFormat') run_command('search', '--web', 'NSAttributedString+CCLFormat')
end end
it "should url encode search queries" do it 'should url encode search queries' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat')
run_command('search', '--web', 'NSAttributedString+CCLFormat') run_command('search', '--web', 'NSAttributedString+CCLFormat')
end end
it "searches the web via the open! command" do it 'searches the web via the open! command' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=bananalib') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=bananalib')
run_command('search', '--web', 'bananalib') run_command('search', '--web', 'bananalib')
end end
it "includes option --osx correctly" do it 'includes option --osx correctly' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aosx%20bananalib') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aosx%20bananalib')
run_command('search', '--web', '--osx', 'bananalib') run_command('search', '--web', '--osx', 'bananalib')
end end
it "includes option --ios correctly" do it 'includes option --ios correctly' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aios%20bananalib') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aios%20bananalib')
run_command('search', '--web', '--ios', 'bananalib') run_command('search', '--web', '--ios', 'bananalib')
end end
it "does not matter in which order the ios/osx options are set" do it 'does not matter in which order the ios/osx options are set' do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib')
run_command('search', '--web', '--ios', '--osx', 'bananalib') run_command('search', '--web', '--ios', '--osx', 'bananalib')
......
...@@ -10,12 +10,12 @@ module Pod ...@@ -10,12 +10,12 @@ module Pod
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
it "returns the read only URL of the `master` spec-repo" do it 'returns the read only URL of the `master` spec-repo' do
cmd = Command::Setup.new(argv) cmd = Command::Setup.new(argv)
cmd.url.should == 'https://github.com/CocoaPods/Specs.git' cmd.url.should == 'https://github.com/CocoaPods/Specs.git'
end end
it "returns the push URL of the `master` spec-repo" do it 'returns the push URL of the `master` spec-repo' do
config.silent = true config.silent = true
cmd = Command::Setup.new(argv('--push')) cmd = Command::Setup.new(argv('--push'))
cmd.url.should == 'git@github.com:CocoaPods/Specs.git' cmd.url.should == 'git@github.com:CocoaPods/Specs.git'
...@@ -27,19 +27,19 @@ module Pod ...@@ -27,19 +27,19 @@ module Pod
config.repos_dir = SpecHelper.temporary_directory config.repos_dir = SpecHelper.temporary_directory
end end
it "runs with correct parameters" do it 'runs with correct parameters' do
lambda { run_command('setup') }.should.not.raise lambda { run_command('setup') }.should.not.raise
end end
it "creates the local spec-repos directory and creates a clone of the `master` repo" do it 'creates the local spec-repos directory and creates a clone of the `master` repo' do
output = run_command('setup') output = run_command('setup')
output.should.include "Setup completed" output.should.include 'Setup completed'
output.should.not.include "push" output.should.not.include 'push'
url = Dir.chdir(config.repos_dir + 'master') { `git config --get remote.origin.url`.chomp } url = Dir.chdir(config.repos_dir + 'master') { `git config --get remote.origin.url`.chomp }
url.should == test_repo_path.to_s url.should == test_repo_path.to_s
end end
it "creates a shallow clone of the `master` repo by default" do it 'creates a shallow clone of the `master` repo by default' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`echo 'touch' > touch && git add touch && git commit -m 'updated'` `echo 'touch' > touch && git add touch && git commit -m 'updated'`
end end
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
end end
end end
it "creates a full clone of the `master` repo if requested" do it 'creates a full clone of the `master` repo if requested' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`echo 'touch' > touch && git add touch && git commit -m 'updated'` `echo 'touch' > touch && git add touch && git commit -m 'updated'`
end end
...@@ -61,7 +61,7 @@ module Pod ...@@ -61,7 +61,7 @@ module Pod
end end
end end
it "creates a full clone of the `master` repo when push access is requested" do it 'creates a full clone of the `master` repo when push access is requested' do
Dir.chdir(test_repo_path) do Dir.chdir(test_repo_path) do
`echo 'touch' > touch && git add touch && git commit -m 'updated'` `echo 'touch' > touch && git add touch && git commit -m 'updated'`
end end
...@@ -73,9 +73,9 @@ module Pod ...@@ -73,9 +73,9 @@ module Pod
end end
end end
it "preserves push access for the `master` repo" do it 'preserves push access for the `master` repo' do
output = run_command('setup') output = run_command('setup')
output.should.not.include "push" output.should.not.include 'push'
Dir.chdir(config.repos_dir + 'master') { `git remote set-url origin git@github.com:CocoaPods/Specs.git` } Dir.chdir(config.repos_dir + 'master') { `git remote set-url origin git@github.com:CocoaPods/Specs.git` }
command('setup').url.should == 'git@github.com:CocoaPods/Specs.git' command('setup').url.should == 'git@github.com:CocoaPods/Specs.git'
end end
...@@ -87,7 +87,7 @@ module Pod ...@@ -87,7 +87,7 @@ module Pod
Command::Setup.any_instance.stubs(:old_master_repo_dir).returns(SpecHelper.temporary_directory + 'cocoapods/master') Command::Setup.any_instance.stubs(:old_master_repo_dir).returns(SpecHelper.temporary_directory + 'cocoapods/master')
end end
it "migrates repos from the old directory structure to the new one" do it 'migrates repos from the old directory structure to the new one' do
source = SpecHelper.temporary_directory + 'cocoapods/master' source = SpecHelper.temporary_directory + 'cocoapods/master'
target = config.repos_dir + 'master' target = config.repos_dir + 'master'
......
...@@ -3,9 +3,9 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,9 +3,9 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Spec do describe Command::Spec do
describe "In general" do describe 'In general' do
it "complains for wrong parameters" do it 'complains for wrong parameters' do
lambda { run_command('spec') }.should.raise CLAide::Help lambda { run_command('spec') }.should.raise CLAide::Help
lambda { run_command('spec', 'create') }.should.raise CLAide::Help lambda { run_command('spec', 'create') }.should.raise CLAide::Help
lambda { run_command('spec', '--create') }.should.raise CLAide::Help lambda { run_command('spec', '--create') }.should.raise CLAide::Help
...@@ -21,59 +21,59 @@ module Pod ...@@ -21,59 +21,59 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "create subcommand" do describe 'create subcommand' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "creates a new podspec stub file" do it 'creates a new podspec stub file' do
run_command('spec', 'create', 'Bananas') run_command('spec', 'create', 'Bananas')
path = temporary_directory + 'Bananas.podspec' path = temporary_directory + 'Bananas.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
spec.name.should == 'Bananas' spec.name.should == 'Bananas'
spec.license.should == { :type => "MIT (example)" } spec.license.should == { :type => 'MIT (example)' }
spec.version.should == Version.new('0.0.1') spec.version.should == Version.new('0.0.1')
spec.summary.should == 'A short description of Bananas.' spec.summary.should == 'A short description of Bananas.'
spec.homepage.should == 'http://EXAMPLE/Bananas' spec.homepage.should == 'http://EXAMPLE/Bananas'
spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip} spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip }
spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' } spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' }
spec.consumer(:ios).source_files.should == ['Classes', 'Classes/**/*.{h,m}'] spec.consumer(:ios).source_files.should == ['Classes', 'Classes/**/*.{h,m}']
spec.consumer(:ios).public_header_files.should == [] spec.consumer(:ios).public_header_files.should == []
end end
it "correctly creates a podspec from github" do it 'correctly creates a podspec from github' do
repo = { repo = {
'name' => 'libPusher', 'name' => 'libPusher',
'owner' => { 'login' => 'lukeredpath' }, 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher', 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)', 'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git' 'clone_url' => 'https://github.com/lukeredpath/libPusher.git',
} }
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo) GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"v1.4"}]) GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'v1.4' }])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" }) GitHub.expects(:user).with('lukeredpath').returns('name' => 'Luke Redpath', 'email' => 'luke@lukeredpath.co.uk')
run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'libPusher.podspec' path = temporary_directory + 'libPusher.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
spec.name.should == 'libPusher' spec.name.should == 'libPusher'
spec.license.should == { :type => "MIT (example)" } spec.license.should == { :type => 'MIT (example)' }
spec.version.should == Version.new('1.4') spec.version.should == Version.new('1.4')
spec.summary.should == 'An Objective-C interface to Pusher (pusherapp.com)' spec.summary.should == 'An Objective-C interface to Pusher (pusherapp.com)'
spec.homepage.should == 'https://github.com/lukeredpath/libPusher' spec.homepage.should == 'https://github.com/lukeredpath/libPusher'
spec.authors.should == {"Luke Redpath"=>"luke@lukeredpath.co.uk"} spec.authors.should == { 'Luke Redpath' => 'luke@lukeredpath.co.uk' }
spec.source.should == { :git => 'https://github.com/lukeredpath/libPusher.git', :tag => 'v1.4' } spec.source.should == { :git => 'https://github.com/lukeredpath/libPusher.git', :tag => 'v1.4' }
end end
it "accepts a name when creating a podspec form github" do it 'accepts a name when creating a podspec form github' do
repo = { repo = {
'name' => 'libPusher', 'name' => 'libPusher',
'owner' => { 'login' => 'lukeredpath' }, 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher', 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)', 'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git' 'clone_url' => 'https://github.com/lukeredpath/libPusher.git',
} }
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo) GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"v1.4"}]) GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'v1.4' }])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" }) GitHub.expects(:user).with('lukeredpath').returns('name' => 'Luke Redpath', 'email' => 'luke@lukeredpath.co.uk')
run_command('spec', 'create', 'other_name', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'other_name', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'other_name.podspec' path = temporary_directory + 'other_name.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
...@@ -81,18 +81,18 @@ module Pod ...@@ -81,18 +81,18 @@ module Pod
spec.homepage.should == 'https://github.com/lukeredpath/libPusher' spec.homepage.should == 'https://github.com/lukeredpath/libPusher'
end end
it "correctly suggests the head commit if a suitable tag is not available on github" do it 'correctly suggests the head commit if a suitable tag is not available on github' do
repo = { repo = {
'name' => 'libPusher', 'name' => 'libPusher',
'owner' => { 'login' => 'lukeredpath' }, 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher', 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)', 'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git' 'clone_url' => 'https://github.com/lukeredpath/libPusher.git',
} }
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo) GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"experiment"}]) GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'experiment' }])
GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"master", "commit" => {'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7'}}]) GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'master', 'commit' => { 'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7' } }])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" }) GitHub.expects(:user).with('lukeredpath').returns('name' => 'Luke Redpath', 'email' => 'luke@lukeredpath.co.uk')
run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'libPusher.podspec' path = temporary_directory + 'libPusher.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
...@@ -106,12 +106,12 @@ module Pod ...@@ -106,12 +106,12 @@ module Pod
'owner' => { 'login' => 'lukeredpath' }, 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher', 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)', 'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git' 'clone_url' => 'https://github.com/lukeredpath/libPusher.git',
} }
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo) GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"experiment"}]) GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'experiment' }])
GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"master", "commit" => {'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7'}}]) GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{ 'name' => 'master', 'commit' => { 'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7' } }])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" }) GitHub.expects(:user).with('lukeredpath').returns('name' => 'Luke Redpath', 'email' => 'luke@lukeredpath.co.uk')
output = run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') output = run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
output.should.include 'MARKDOWN TEMPLATE' output.should.include 'MARKDOWN TEMPLATE'
output.should.include 'Please add semantic version tags' output.should.include 'Please add semantic version tags'
...@@ -120,7 +120,7 @@ module Pod ...@@ -120,7 +120,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "lint subcommand" do describe 'lint subcommand' do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "complains if it can't find any spec to lint" do it "complains if it can't find any spec to lint" do
...@@ -135,16 +135,16 @@ module Pod ...@@ -135,16 +135,16 @@ module Pod
end end
end end
it "lints the current working directory" do it 'lints the current working directory' do
Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do
cmd = command('spec', 'lint', '--quick', '--only-errors') cmd = command('spec', 'lint', '--quick', '--only-errors')
cmd.run cmd.run
UI.output.should.include "passed validation" UI.output.should.include 'passed validation'
end end
end end
# @todo VCR is required in CocoaPods only for this test. # @todo VCR is required in CocoaPods only for this test.
xit "lints a remote podspec" do xit 'lints a remote podspec' do
Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do
cmd = command('spec', 'lint', '--quick', '--only-errors', '--silent', 'https://github.com/CocoaPods/Specs/raw/master/A2DynamicDelegate/2.0.1/A2DynamicDelegate.podspec') cmd = command('spec', 'lint', '--quick', '--only-errors', '--silent', 'https://github.com/CocoaPods/Specs/raw/master/A2DynamicDelegate/2.0.1/A2DynamicDelegate.podspec')
# VCR.use_cassette('linter', :record => :new_episodes) { } # VCR.use_cassette('linter', :record => :new_episodes) { }
...@@ -156,20 +156,20 @@ module Pod ...@@ -156,20 +156,20 @@ module Pod
text = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read text = (fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json').read
text.gsub!(/.*license.*/, '"license": { "file": "LICENSE" },') text.gsub!(/.*license.*/, '"license": { "file": "LICENSE" },')
file = temporary_directory + 'JSONKit.podspec.json' file = temporary_directory + 'JSONKit.podspec.json'
File.open(file, 'w') {|f| f.write(text) } File.open(file, 'w') { |f| f.write(text) }
@spec_path = file.to_s @spec_path = file.to_s
end end
it "lints a given podspec" do it 'lints a given podspec' do
cmd = command('spec', 'lint', '--quick', @spec_path) cmd = command('spec', 'lint', '--quick', @spec_path)
lambda { cmd.run }.should.raise Informative lambda { cmd.run }.should.raise Informative
UI.output.should.include "Missing license type" UI.output.should.include 'Missing license type'
end end
it "respects the -only--errors option" do it 'respects the -only--errors option' do
cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path) cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path)
lambda { cmd.run }.should.not.raise lambda { cmd.run }.should.not.raise
UI.output.should.include "Missing license type" UI.output.should.include 'Missing license type'
end end
end end
...@@ -183,19 +183,19 @@ module Pod ...@@ -183,19 +183,19 @@ module Pod
end end
def it_should_check_for_ambiguity(command) def it_should_check_for_ambiguity(command)
it "complains provided spec name is ambigious" do it 'complains provided spec name is ambigious' do
e = lambda { command('spec', command, 'AF').run }.should.raise Informative e = lambda { command('spec', command, 'AF').run }.should.raise Informative
e.message.should.match /More than one/ e.message.should.match /More than one/
end end
end end
describe Command::Spec::Which do describe Command::Spec::Which do
it_should_check_for_existence("which") it_should_check_for_existence('which')
it_should_check_for_ambiguity("which") it_should_check_for_ambiguity('which')
it "prints the path of a given podspec" do it 'prints the path of a given podspec' do
lambda { command('spec', 'which', 'AFNetworking').run }.should.not.raise lambda { command('spec', 'which', 'AFNetworking').run }.should.not.raise
text = "AFNetworking.podspec" text = 'AFNetworking.podspec'
UI.output.should.include text.gsub(/\n/, '') UI.output.should.include text.gsub(/\n/, '')
end end
end end
...@@ -203,15 +203,15 @@ module Pod ...@@ -203,15 +203,15 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe Command::Spec::Cat do describe Command::Spec::Cat do
it_should_check_for_existence("cat") it_should_check_for_existence('cat')
it_should_check_for_ambiguity("cat") it_should_check_for_ambiguity('cat')
it "cats the given podspec" do it 'cats the given podspec' do
lambda { command('spec', 'cat', 'AFNetworking').run }.should.not.raise lambda { command('spec', 'cat', 'AFNetworking').run }.should.not.raise
UI.output.should.include fixture('spec-repos/master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json').read UI.output.should.include fixture('spec-repos/master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json').read
end end
it "cats the first podspec from all podspecs" do it 'cats the first podspec from all podspecs' do
UI.next_input = "1\n" UI.next_input = "1\n"
run_command('spec', 'cat', '--show-all', 'AFNetworking') run_command('spec', 'cat', '--show-all', 'AFNetworking')
UI.output.should.include fixture('spec-repos/master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json').read UI.output.should.include fixture('spec-repos/master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json').read
...@@ -229,23 +229,23 @@ module Pod ...@@ -229,23 +229,23 @@ module Pod
ENV['PATH'] = @path_saved ENV['PATH'] = @path_saved
end end
it_should_check_for_existence("edit") it_should_check_for_existence('edit')
it_should_check_for_ambiguity("edit") it_should_check_for_ambiguity('edit')
it "would execute the editor specified in ENV with the given podspec" do it 'would execute the editor specified in ENV with the given podspec' do
ENV['EDITOR'] = 'podspeceditor' ENV['EDITOR'] = 'podspeceditor'
lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise SystemExit lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise SystemExit
UI.output.should.include '/bin/sh -i -c podspeceditor "$@" --' UI.output.should.include '/bin/sh -i -c podspeceditor "$@" --'
UI.output.should.include 'fixtures/spec-repos/master/Specs/AFNetworking' UI.output.should.include 'fixtures/spec-repos/master/Specs/AFNetworking'
end end
it "will raise if no editor is found" do it 'will raise if no editor is found' do
ENV['PATH'] = '' ENV['PATH'] = ''
ENV['EDITOR'] = nil ENV['EDITOR'] = nil
lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise Informative lambda { command('spec', 'edit', 'AFNetworking').run }.should.raise Informative
end end
it "would execute an editor with the first podspec from all podspecs" do it 'would execute an editor with the first podspec from all podspecs' do
ENV['EDITOR'] = 'podspeceditor' ENV['EDITOR'] = 'podspeceditor'
UI.next_input = "1\n" UI.next_input = "1\n"
lambda { command('spec', 'edit', '--show-all', 'AFNetworking').run }.should.raise SystemExit lambda { command('spec', 'edit', '--show-all', 'AFNetworking').run }.should.raise SystemExit
...@@ -262,7 +262,7 @@ module Pod ...@@ -262,7 +262,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private helpers" do describe 'Private helpers' do
before do before do
# TODO Use class methods # TODO Use class methods
...@@ -270,29 +270,29 @@ module Pod ...@@ -270,29 +270,29 @@ module Pod
end end
describe "#get_path_of_spec" do describe '#get_path_of_spec' do
it "returns the path of the specification with the given name" do it 'returns the path of the specification with the given name' do
path = @sut.send(:get_path_of_spec, 'AFNetworking') path = @sut.send(:get_path_of_spec, 'AFNetworking')
path.should == fixture('spec-repos') + 'master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json' path.should == fixture('spec-repos') + 'master/Specs/AFNetworking/2.3.1/AFNetworking.podspec.json'
end end
end end
describe "#choose_from_array" do describe '#choose_from_array' do
it "should return a valid index for the given array" do it 'should return a valid index for the given array' do
UI.next_input = "1\n" UI.next_input = "1\n"
index = @sut.send(:choose_from_array, ['item1', 'item2', 'item3'], 'A message') index = @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message')
UI.output.should.include "1: item1\n2: item2\n3: item3\nA message\n" UI.output.should.include "1: item1\n2: item2\n3: item3\nA message\n"
index.should == 0 index.should == 0
end end
it "should raise when the index is out of bounds" do it 'should raise when the index is out of bounds' do
UI.next_input = "4\n" UI.next_input = "4\n"
lambda { @sut.send(:choose_from_array, ['item1', 'item2', 'item3'], 'A message') }.should.raise Pod::Informative lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
UI.next_input = "0\n" UI.next_input = "0\n"
lambda { @sut.send(:choose_from_array, ['item1', 'item2', 'item3'], 'A message') }.should.raise Pod::Informative lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
end end
end end
...@@ -303,4 +303,3 @@ module Pod ...@@ -303,4 +303,3 @@ module Pod
end end
end end
...@@ -4,12 +4,12 @@ module Pod ...@@ -4,12 +4,12 @@ module Pod
describe Command do describe Command do
extend SpecHelper::Command extend SpecHelper::Command
it "displays the current version number with the --version flag" do it 'displays the current version number with the --version flag' do
Pod::Command.version.should == VERSION Pod::Command.version.should == VERSION
end end
it "reports the location of the AFNetworking spec" do it 'reports the location of the AFNetworking spec' do
lambda { Pod::Command.run(['spec', 'which', 'AFNetworking']) }.should.not.raise lambda { Pod::Command.run(%w(spec which AFNetworking)) }.should.not.raise
UI.output.should.include 'spec/fixtures/spec-repos/master/Specs/AFNetworking' UI.output.should.include 'spec/fixtures/spec-repos/master/Specs/AFNetworking'
end end
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
@set = SourcesManager.search(Dependency.new('CocoaLumberjack')) @set = SourcesManager.search(Dependency.new('CocoaLumberjack'))
end end
it "presents the name, version, description, homepage and source of a specification set" do it 'presents the name, version, description, homepage and source of a specification set' do
UI.pod(@set) UI.pod(@set)
output = UI.output output = UI.output
output.should.include? 'CocoaLumberjack' output.should.include? 'CocoaLumberjack'
...@@ -21,26 +21,26 @@ module Pod ...@@ -21,26 +21,26 @@ module Pod
output.should.include? 'https://github.com/CocoaLumberjack/CocoaLumberjack.git' output.should.include? 'https://github.com/CocoaLumberjack/CocoaLumberjack.git'
end end
it "Presents information about deprecation if the pod is deprecated" do it 'Presents information about deprecation if the pod is deprecated' do
specification = @set.specification specification = @set.specification
specification.deprecated = true specification.deprecated = true
@set.expects(:specification).returns(specification) @set.expects(:specification).returns(specification)
UI.pod(@set) UI.pod(@set)
output = UI.output output = UI.output
output.should.include? "[DEPRECATED]" output.should.include? '[DEPRECATED]'
end end
it "Presents information about the deprecation in favor of another pod" do it 'Presents information about the deprecation in favor of another pod' do
specification = @set.specification specification = @set.specification
specification.deprecated_in_favor_of = "NewMoreAwesomePod" specification.deprecated_in_favor_of = 'NewMoreAwesomePod'
@set.expects(:specification).returns(specification) @set.expects(:specification).returns(specification)
UI.pod(@set) UI.pod(@set)
output = UI.output output = UI.output
output.should.include? "[DEPRECATED in favor of NewMoreAwesomePod]" output.should.include? '[DEPRECATED in favor of NewMoreAwesomePod]'
end end
it "presents the stats of a specification set" do it 'presents the stats of a specification set' do
Specification::Set::Presenter.any_instance.expects(:github_last_activity).returns('more than a year ago') Specification::Set::Presenter.any_instance.expects(:github_last_activity).returns('more than a year ago')
Specification::Set::Presenter.any_instance.expects(:github_watchers).returns('318') Specification::Set::Presenter.any_instance.expects(:github_watchers).returns('318')
Specification::Set::Presenter.any_instance.expects(:github_forks).returns('42') Specification::Set::Presenter.any_instance.expects(:github_forks).returns('42')
...@@ -54,14 +54,14 @@ module Pod ...@@ -54,14 +54,14 @@ module Pod
output.should.include? 'Pushed: more than a year ago' output.should.include? 'Pushed: more than a year ago'
end end
it "should print at least one subspec" do it 'should print at least one subspec' do
@set = SourcesManager.search(Dependency.new('RestKit')) @set = SourcesManager.search(Dependency.new('RestKit'))
UI.pod(@set) UI.pod(@set)
output = UI.output output = UI.output
output.should.include? "RestKit/Network" output.should.include? 'RestKit/Network'
end end
it "presents only name and version of a specification set in :name_and_version mode" do it 'presents only name and version of a specification set in :name_and_version mode' do
@set = SourcesManager.search_by_name('RestKit').first @set = SourcesManager.search_by_name('RestKit').first
UI.pod(@set, :name_and_version) UI.pod(@set, :name_and_version)
output = UI.output output = UI.output
......
...@@ -37,29 +37,28 @@ ...@@ -37,29 +37,28 @@
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# @return [Pathname] The root of the repo. # @return [Pathname] The root of the repo.
# #
ROOT = Pathname.new(File.expand_path("../../", __FILE__)) unless defined? ROOT ROOT = Pathname.new(File.expand_path('../../', __FILE__)) unless defined? ROOT
$:.unshift((ROOT + 'spec').to_s) $:.unshift((ROOT + 'spec').to_s)
require 'rubygems' require 'rubygems'
require 'bundler/setup' require 'bundler/setup'
require 'pretty_bacon' require 'pretty_bacon'
require 'colored' require 'colored'
require "clintegracon" require 'clintegracon'
require "integration/xcodeproj_project_yaml" require 'integration/xcodeproj_project_yaml'
CLIntegracon.configure do |c| CLIntegracon.configure do |c|
c.spec_path = ROOT + "spec/cocoapods-integration-specs" c.spec_path = ROOT + 'spec/cocoapods-integration-specs'
c.temp_path = ROOT + "tmp" c.temp_path = ROOT + 'tmp'
# Transform produced project files to YAMLs # Transform produced project files to YAMLs
c.transform_produced "**/*.xcodeproj" do |path| c.transform_produced '**/*.xcodeproj' do |path|
# Creates a YAML representation of the Xcodeproj files # Creates a YAML representation of the Xcodeproj files
# which should be used as a reference for comparison. # which should be used as a reference for comparison.
xcodeproj = Xcodeproj::Project.open(path) xcodeproj = Xcodeproj::Project.open(path)
File.open("#{path}.yaml", "w") do |file| File.open("#{path}.yaml", 'w') do |file|
file.write xcodeproj.to_yaml file.write xcodeproj.to_yaml
end end
end end
...@@ -67,156 +66,155 @@ CLIntegracon.configure do |c| ...@@ -67,156 +66,155 @@ CLIntegracon.configure do |c|
# Register special handling for YAML files # Register special handling for YAML files
paths = [%r{Podfile\.lock}, %r{Manifest\.lock$}, %r{xcodeproj\.yaml$}] paths = [%r{Podfile\.lock}, %r{Manifest\.lock$}, %r{xcodeproj\.yaml$}]
c.has_special_handling_for *paths do |path| c.has_special_handling_for *paths do |path|
if RUBY_VERSION < "1.9" if RUBY_VERSION < '1.9'
nil # CP is not sorting array derived from hashes whose order is nil # CP is not sorting array derived from hashes whose order is
# undefined in 1.8.7 # undefined in 1.8.7
else else
# Remove CocoaPods version # Remove CocoaPods version
yaml = File.open(path) { |f| YAML.load(f) } yaml = File.open(path) { |f| YAML.load(f) }
yaml.delete("COCOAPODS") yaml.delete('COCOAPODS')
yaml.to_s yaml.to_s
end end
end end
# So we don't need to compare them directly # So we don't need to compare them directly
c.ignores %r{\.xcodeproj/} c.ignores %r{\.xcodeproj/}
c.ignores "Podfile" c.ignores 'Podfile'
# Ignore certain OSX files # Ignore certain OSX files
c.ignores ".DS_Store" c.ignores '.DS_Store'
# Ignore xcuserdata # Ignore xcuserdata
c.ignores %r{/xcuserdata/} c.ignores %r{/xcuserdata/}
# TODO The output from the caches changes on Travis # TODO The output from the caches changes on Travis
c.ignores "execution_output.txt" c.ignores 'execution_output.txt'
# Needed for some test cases # Needed for some test cases
c.ignores "Reachability.podspec" c.ignores 'Reachability.podspec'
c.ignores "PodTest-hg-source/**" c.ignores 'PodTest-hg-source/**'
c.hook_into :bacon c.hook_into :bacon
end end
describe_cli 'pod' do
describe_cli "pod" do
subject do |s| subject do |s|
s.executable = "ruby #{ROOT + "bin/pod"}" s.executable = "ruby #{ROOT + 'bin/pod'}"
s.environment_vars = { s.environment_vars = {
"CP_AGGRESSIVE_CACHE" => "TRUE", 'CP_AGGRESSIVE_CACHE' => 'TRUE',
"XCODEPROJ_DISABLE_XCPROJ" => "TRUE", 'XCODEPROJ_DISABLE_XCPROJ' => 'TRUE',
} }
s.default_args = [ s.default_args = [
"--verbose", '--verbose',
"--no-ansi" '--no-ansi',
] ]
s.replace_path ROOT.to_s, "ROOT" s.replace_path ROOT.to_s, 'ROOT'
s.replace_user_path "Library/Caches/CocoaPods", "CACHES_DIR" s.replace_user_path 'Library/Caches/CocoaPods', 'CACHES_DIR'
end end
describe "Pod install" do describe 'Pod install' do
# Test installation with no integration # Test installation with no integration
# Test subspecs inheritance # Test subspecs inheritance
describe "Integrates a project with CocoaPods" do describe 'Integrates a project with CocoaPods' do
behaves_like cli_spec "install_new", behaves_like cli_spec 'install_new',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Adds a Pod to an existing installation" do describe 'Adds a Pod to an existing installation' do
behaves_like cli_spec "install_add_pod", behaves_like cli_spec 'install_add_pod',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Removes a Pod from an existing installation" do describe 'Removes a Pod from an existing installation' do
behaves_like cli_spec "install_remove_pod", behaves_like cli_spec 'install_remove_pod',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Creates an installation with multiple target definitions" do describe 'Creates an installation with multiple target definitions' do
behaves_like cli_spec "install_multiple_targets", behaves_like cli_spec 'install_multiple_targets',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Installs a Pod with different subspecs activated across different targets" do describe 'Installs a Pod with different subspecs activated across different targets' do
behaves_like cli_spec "install_subspecs", behaves_like cli_spec 'install_subspecs',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Installs a Pod with subspecs and does not duplicate the prefix header" do describe 'Installs a Pod with subspecs and does not duplicate the prefix header' do
behaves_like cli_spec "install_subspecs_no_duplicate_prefix", behaves_like cli_spec 'install_subspecs_no_duplicate_prefix',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Installs a Pod with a local source" do describe 'Installs a Pod with a local source' do
behaves_like cli_spec "install_local_source", behaves_like cli_spec 'install_local_source',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Installs a Pod with an external source" do describe 'Installs a Pod with an external source' do
behaves_like cli_spec "install_external_source", behaves_like cli_spec 'install_external_source',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Installs a Pod given the podspec" do describe 'Installs a Pod given the podspec' do
behaves_like cli_spec "install_podspec", behaves_like cli_spec 'install_podspec',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Performs an installation using a custom workspace" do describe 'Performs an installation using a custom workspace' do
behaves_like cli_spec "install_custom_workspace", behaves_like cli_spec 'install_custom_workspace',
"install --no-repo-update" 'install --no-repo-update'
end end
describe "Integrates a target with custom build settings" do describe 'Integrates a target with custom build settings' do
behaves_like cli_spec "install_custom_build_configuration", behaves_like cli_spec 'install_custom_build_configuration',
"install --no-repo-update" 'install --no-repo-update'
end end
# @todo add tests for all the hooks API # @todo add tests for all the hooks API
# #
describe "Runs the Podfile callbacks" do describe 'Runs the Podfile callbacks' do
behaves_like cli_spec "install_podfile_callbacks", behaves_like cli_spec 'install_podfile_callbacks',
"install --no-repo-update" 'install --no-repo-update'
end end
end end
#--------------------------------------# #--------------------------------------#
describe "Pod update" do describe 'Pod update' do
describe "Updates an existing installation" do describe 'Updates an existing installation' do
behaves_like cli_spec "update_all", behaves_like cli_spec 'update_all',
"update --no-repo-update" 'update --no-repo-update'
end end
describe "Updates a selected Pod in an existing installation" do describe 'Updates a selected Pod in an existing installation' do
behaves_like cli_spec "update_selected", behaves_like cli_spec 'update_selected',
"update Reachability --no-repo-update" 'update Reachability --no-repo-update'
end end
end end
#--------------------------------------# #--------------------------------------#
describe "Pod lint" do describe 'Pod lint' do
describe "Lints a Pod" do describe 'Lints a Pod' do
behaves_like cli_spec "spec_lint", behaves_like cli_spec 'spec_lint',
"spec lint --quick" 'spec lint --quick'
end end
end end
#--------------------------------------# #--------------------------------------#
describe "Pod init" do describe 'Pod init' do
describe "Initializes a Podfile with a single platform" do describe 'Initializes a Podfile with a single platform' do
behaves_like cli_spec "init_single_platform", behaves_like cli_spec 'init_single_platform',
"init" 'init'
end end
end end
......
require "xcodeproj" require 'xcodeproj'
require "yaml" require 'yaml'
class Xcodeproj::Project class Xcodeproj::Project
def to_yaml def to_yaml
pretty_print_output = pretty_print pretty_print_output = pretty_print
sections = [] sections = []
sorted_keys = ["File References", "Targets", "Build Configurations"] sorted_keys = ['File References', 'Targets', 'Build Configurations']
sorted_keys.each do |key| sorted_keys.each do |key|
yaml = { key => pretty_print_output[key] }.to_yaml yaml = { key => pretty_print_output[key] }.to_yaml
sections << yaml sections << yaml
end end
(sections * "\n\n").gsub!("---", '') (sections * "\n\n").gsub!('---', '')
end end
end end
...@@ -26,7 +26,7 @@ require 'bacon' ...@@ -26,7 +26,7 @@ require 'bacon'
require 'mocha-on-bacon' require 'mocha-on-bacon'
require 'pretty_bacon' require 'pretty_bacon'
require 'pathname' require 'pathname'
require "active_support/core_ext/string/strip" require 'active_support/core_ext/string/strip'
ROOT = Pathname.new(File.expand_path('../../', __FILE__)) ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$:.unshift((ROOT + 'lib').to_s) $:.unshift((ROOT + 'lib').to_s)
...@@ -34,7 +34,7 @@ $:.unshift((ROOT + 'spec').to_s) ...@@ -34,7 +34,7 @@ $:.unshift((ROOT + 'spec').to_s)
require 'cocoapods' require 'cocoapods'
require 'claide' require 'claide'
#require 'awesome_print' # require 'awesome_print'
require 'spec_helper/command' # Allows to run Pod commands and returns their output. require 'spec_helper/command' # Allows to run Pod commands and returns their output.
require 'spec_helper/fixture' # Provides access to the fixtures and unpacks them if needed. require 'spec_helper/fixture' # Provides access to the fixtures and unpacks them if needed.
...@@ -52,7 +52,7 @@ require 'spec_helper/github' # Stubs Github API to return always the va ...@@ -52,7 +52,7 @@ require 'spec_helper/github' # Stubs Github API to return always the va
# #
module Pod module Pod
class Specification class Specification
alias :original_source :source alias_method :original_source, :source
def source def source
fixture = SpecHelper.fixture("integration/#{name}") fixture = SpecHelper.fixture("integration/#{name}")
result = super result = super
...@@ -117,7 +117,7 @@ module SpecHelper ...@@ -117,7 +117,7 @@ module SpecHelper
end end
def temporary_sandbox def temporary_sandbox
Pod::Sandbox.new(temporary_directory + "Pods") Pod::Sandbox.new(temporary_directory + 'Pods')
end end
def fixture_spec(name) def fixture_spec(name)
...@@ -135,4 +135,3 @@ end ...@@ -135,4 +135,3 @@ end
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
SpecHelper::Fixture.fixture('banana-lib') # ensure it exists SpecHelper::Fixture.fixture('banana-lib') # ensure it exists
# # require 'octokit' # # require 'octokit'
# #
# module SpecHelper # module SpecHelper
# module Github # module Github
# def expect_github_repo_request(data = nil) # def expect_github_repo_request(data = nil)
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
# } # }
# Octokit.expects(:repo).with('lukeredpath/libPusher').returns(data) # Octokit.expects(:repo).with('lukeredpath/libPusher').returns(data)
# end # end
# #
# def expect_github_tags_request(data = nil) # def expect_github_tags_request(data = nil)
# data ||= [ # data ||= [
# { # {
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
# ] # ]
# Octokit.expects(:tags).with(:username => 'lukeredpath', :repo => 'libPusher').returns(data) # Octokit.expects(:tags).with(:username => 'lukeredpath', :repo => 'libPusher').returns(data)
# end # end
# #
# def expect_github_branches_request(data = nil) # def expect_github_branches_request(data = nil)
# data ||= [ # data ||= [
# { # {
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
# ] # ]
# Octokit.expects(:branches).with(:username => 'lukeredpath', :repo => 'libPusher').returns(data) # Octokit.expects(:branches).with(:username => 'lukeredpath', :repo => 'libPusher').returns(data)
# end # end
# #
# def expect_github_user_request(data = nil) # def expect_github_user_request(data = nil)
# data ||= { # data ||= {
# "avatar_url" => "https://secure.gravatar.com/avatar/bdd4d23d1a822b2d68b53e7c51d69a39?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", # "avatar_url" => "https://secure.gravatar.com/avatar/bdd4d23d1a822b2d68b53e7c51d69a39?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
...@@ -143,4 +143,4 @@ ...@@ -143,4 +143,4 @@
# end # end
# end # end
# end # end
# #
...@@ -31,4 +31,3 @@ module Bacon ...@@ -31,4 +31,3 @@ module Bacon
end end
end end
end end
...@@ -88,4 +88,3 @@ module SpecHelper ...@@ -88,4 +88,3 @@ module SpecHelper
end end
end end
end end
module Pod module Pod
# Disable the wrapping so the output is deterministic in the tests. # Disable the wrapping so the output is deterministic in the tests.
# #
UI.disable_wrap = true UI.disable_wrap = true
...@@ -20,7 +19,7 @@ module Pod ...@@ -20,7 +19,7 @@ module Pod
@output << "#{message}\n" @output << "#{message}\n"
end end
def warn(message = '', actions = []) def warn(message = '', _actions = [])
@warnings << "#{message}\n" @warnings << "#{message}\n"
end end
......
...@@ -2,21 +2,21 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,21 +2,21 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Command do describe Command do
it "returns the proper command class" do it 'returns the proper command class' do
Command.parse(%w{ help }).should.be.instance_of Command::Help Command.parse(%w( help )).should.be.instance_of Command::Help
Command.parse(%w{ install }).should.be.instance_of Command::Install Command.parse(%w( install )).should.be.instance_of Command::Install
Command.parse(%w{ list }).should.be.instance_of Command::List Command.parse(%w( list )).should.be.instance_of Command::List
Command.parse(%w{ outdated }).should.be.instance_of Command::Outdated Command.parse(%w( outdated )).should.be.instance_of Command::Outdated
Command.parse(%w{ repo }).should.be.instance_of Command::Repo Command.parse(%w( repo )).should.be.instance_of Command::Repo
Command.parse(%w{ repo add }).should.be.instance_of Command::Repo::Add Command.parse(%w( repo add )).should.be.instance_of Command::Repo::Add
Command.parse(%w{ repo lint }).should.be.instance_of Command::Repo::Lint Command.parse(%w( repo lint )).should.be.instance_of Command::Repo::Lint
Command.parse(%w{ repo update }).should.be.instance_of Command::Repo::Update Command.parse(%w( repo update )).should.be.instance_of Command::Repo::Update
Command.parse(%w{ repo remove }).should.be.instance_of Command::Repo::Remove Command.parse(%w( repo remove )).should.be.instance_of Command::Repo::Remove
Command.parse(%w{ search }).should.be.instance_of Command::Search Command.parse(%w( search )).should.be.instance_of Command::Search
Command.parse(%w{ setup }).should.be.instance_of Command::Setup Command.parse(%w( setup )).should.be.instance_of Command::Setup
Command.parse(%w{ spec create }).should.be.instance_of Command::Spec::Create Command.parse(%w( spec create )).should.be.instance_of Command::Spec::Create
Command.parse(%w{ spec lint }).should.be.instance_of Command::Spec::Lint Command.parse(%w( spec lint )).should.be.instance_of Command::Spec::Lint
Command.parse(%w{ init }).should.be.instance_of Command::Init Command.parse(%w( init )).should.be.instance_of Command::Init
end end
end end
end end
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Config do describe Config do
before do before do
@sut = Config.new(false) @sut = Config.new(false)
...@@ -9,56 +8,56 @@ module Pod ...@@ -9,56 +8,56 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "In general" do describe 'In general' do
it "returns the singleton config instance" do it 'returns the singleton config instance' do
@sut.should.be.instance_of Config @sut.should.be.instance_of Config
end end
it "returns the path to the home dir" do it 'returns the path to the home dir' do
@sut.home_dir.should == Pathname.new("~/.cocoapods").expand_path @sut.home_dir.should == Pathname.new('~/.cocoapods').expand_path
end end
it "returns the path to the spec-repos dir" do it 'returns the path to the spec-repos dir' do
@sut.repos_dir.should == Pathname.new("~/.cocoapods/repos").expand_path @sut.repos_dir.should == Pathname.new('~/.cocoapods/repos').expand_path
end end
it "returns the path to the templates dir" do it 'returns the path to the templates dir' do
@sut.templates_dir.should == Pathname.new("~/.cocoapods/templates").expand_path @sut.templates_dir.should == Pathname.new('~/.cocoapods/templates').expand_path
end end
it "returns the path of the default podfiles" do it 'returns the path of the default podfiles' do
@sut.default_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.default").expand_path @sut.default_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.default').expand_path
@sut.default_test_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.test").expand_path @sut.default_test_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.test').expand_path
end end
it "allows to specify the home dir with an environment variable" do it 'allows to specify the home dir with an environment variable' do
ENV['CP_HOME_DIR'] = '~/custom_home_dir' ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new("~/custom_home_dir").expand_path @sut.home_dir.should == Pathname.new('~/custom_home_dir').expand_path
ENV.delete('CP_HOME_DIR') ENV.delete('CP_HOME_DIR')
end end
it "allows to specify the repos dir with an environment variable" do it 'allows to specify the repos dir with an environment variable' do
ENV['CP_REPOS_DIR'] = '~/custom_repos_dir' ENV['CP_REPOS_DIR'] = '~/custom_repos_dir'
@sut.repos_dir.should == Pathname.new("~/custom_repos_dir").expand_path @sut.repos_dir.should == Pathname.new('~/custom_repos_dir').expand_path
ENV.delete('CP_REPOS_DIR') ENV.delete('CP_REPOS_DIR')
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Paths" do describe 'Paths' do
it "returns the working directory as the installation root if a Podfile can be found" do it 'returns the working directory as the installation root if a Podfile can be found' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {} File.open('Podfile', 'w') {}
@sut.installation_root.should == temporary_directory @sut.installation_root.should == temporary_directory
end end
end end
it "returns the parent directory which contains the Podfile if it can be found" do it 'returns the parent directory which contains the Podfile if it can be found' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {} File.open('Podfile', 'w') {}
sub_dir = temporary_directory + 'sub_dir' sub_dir = temporary_directory + 'sub_dir'
sub_dir.mkpath sub_dir.mkpath
Dir.chdir(sub_dir) do Dir.chdir(sub_dir) do
...@@ -67,7 +66,7 @@ module Pod ...@@ -67,7 +66,7 @@ module Pod
end end
end end
it "it returns the working directory as the installation root if no Podfile can be found" do it 'it returns the working directory as the installation root if no Podfile can be found' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
@sut.installation_root.should == temporary_directory @sut.installation_root.should == temporary_directory
end end
...@@ -77,55 +76,55 @@ module Pod ...@@ -77,55 +76,55 @@ module Pod
@sut.installation_root = temporary_directory @sut.installation_root = temporary_directory
end end
it "returns the path to the project root" do it 'returns the path to the project root' do
@sut.installation_root.should == temporary_directory @sut.installation_root.should == temporary_directory
end end
it "returns the path to the project Podfile if it exists" do it 'returns the path to the project Podfile if it exists' do
(temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' } (temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'Podfile' @sut.podfile_path.should == temporary_directory + 'Podfile'
end end
it "can detect yaml Podfiles" do it 'can detect yaml Podfiles' do
(temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' } (temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml' @sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
end end
it "can detect files named `CocoaPods.podfile`" do it 'can detect files named `CocoaPods.podfile`' do
(temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' } (temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile' @sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
end end
it "returns the path to the Pods directory that holds the dependencies" do it 'returns the path to the Pods directory that holds the dependencies' do
@sut.sandbox_root.should == temporary_directory + 'Pods' @sut.sandbox_root.should == temporary_directory + 'Pods'
end end
it "returns the Podfile path" do it 'returns the Podfile path' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {} File.open('Podfile', 'w') {}
@sut.podfile_path.should == temporary_directory + "Podfile" @sut.podfile_path.should == temporary_directory + 'Podfile'
end end
end end
it "returns nils if the Podfile if no paths exists" do it 'returns nils if the Podfile if no paths exists' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
@sut.podfile_path.should == nil @sut.podfile_path.should.nil?
end end
end end
it "returns the Lockfile path" do it 'returns the Lockfile path' do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {} File.open('Podfile', 'w') {}
File.open("Podfile.lock", "w") {} File.open('Podfile.lock', 'w') {}
@sut.lockfile_path.should == temporary_directory + "Podfile.lock" @sut.lockfile_path.should == temporary_directory + 'Podfile.lock'
end end
end end
it "returns the statistics cache file" do it 'returns the statistics cache file' do
@sut.statistics_cache_file.to_s.should.end_with?('statistics.yml') @sut.statistics_cache_file.to_s.should.end_with?('statistics.yml')
end end
it "returns the search index file" do it 'returns the search index file' do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml') @sut.search_index_file.to_s.should.end_with?('search_index.yaml')
end end
...@@ -133,30 +132,30 @@ module Pod ...@@ -133,30 +132,30 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Default settings" do describe 'Default settings' do
it "prints out normal information" do it 'prints out normal information' do
@sut.should.not.be.silent @sut.should.not.be.silent
end end
it "does not print verbose information" do it 'does not print verbose information' do
@sut.should.not.be.verbose @sut.should.not.be.verbose
end end
it "cleans SCM dirs in dependency checkouts" do it 'cleans SCM dirs in dependency checkouts' do
@sut.should.clean @sut.should.clean
end end
it "returns the cache root" do it 'returns the cache root' do
@sut.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods')) @sut.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Dependency Injection" do describe 'Dependency Injection' do
it "returns the specification statistics provider" do it 'returns the specification statistics provider' do
stats_provider = @sut.spec_statistics_provider stats_provider = @sut.spec_statistics_provider
stats_provider.cache_file.should == @sut.cache_root + 'statistics.yml' stats_provider.cache_file.should == @sut.cache_root + 'statistics.yml'
end end
...@@ -165,13 +164,13 @@ module Pod ...@@ -165,13 +164,13 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private helpers" do describe 'Private helpers' do
it "returns the path of the user settings file" do it 'returns the path of the user settings file' do
@sut.send(:user_settings_file).should == Pathname.new("~/.cocoapods/config.yaml").expand_path @sut.send(:user_settings_file).should == Pathname.new('~/.cocoapods/config.yaml').expand_path
end end
it "can be configured with a hash" do it 'can be configured with a hash' do
hash = { :verbose => true } hash = { :verbose => true }
@sut.send(:configure_with, hash) @sut.send(:configure_with, hash)
@sut.should.be.verbose @sut.should.be.verbose
...@@ -179,32 +178,32 @@ module Pod ...@@ -179,32 +178,32 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#podfile_path_in_dir" do describe '#podfile_path_in_dir' do
it "detects the CocoaPods.podfile.yaml file" do it 'detects the CocoaPods.podfile.yaml file' do
expected = temporary_directory + "CocoaPods.podfile.yaml" expected = temporary_directory + 'CocoaPods.podfile.yaml'
File.open(expected, "w") {} File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory) path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected path.should == expected
end end
it "detects the CocoaPods.podfile file" do it 'detects the CocoaPods.podfile file' do
expected = temporary_directory + "CocoaPods.podfile" expected = temporary_directory + 'CocoaPods.podfile'
File.open(expected, "w") {} File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory) path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected path.should == expected
end end
it "detects the Podfile file" do it 'detects the Podfile file' do
expected = temporary_directory + "Podfile" expected = temporary_directory + 'Podfile'
File.open(expected, "w") {} File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory) path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected path.should == expected
end end
it "returns nils if the Podfile is not available" do it 'returns nils if the Podfile is not available' do
path = @sut.send(:podfile_path_in_dir, temporary_directory) path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == nil path.should.nil?
end end
end end
......
...@@ -3,8 +3,10 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,8 +3,10 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Executable do describe Executable do
it 'shows the actual command on failure' do it 'shows the actual command on failure' do
e = lambda { Executable.execute_command('false', e = lambda do
'', true) }.should.raise Informative Executable.execute_command('false',
'', true)
end.should.raise Informative
e.message.should.match(/false/) e.message.should.match(/false/)
end end
end end
......
...@@ -4,26 +4,26 @@ module Pod ...@@ -4,26 +4,26 @@ module Pod
describe ExternalSources::AbstractExternalSource do describe ExternalSources::AbstractExternalSource do
before do before do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) dependency = Dependency.new('Reachability', :git => fixture('integration/Reachability'))
@subject = ExternalSources.from_dependency(dependency, nil) @subject = ExternalSources.from_dependency(dependency, nil)
end end
#--------------------------------------# #--------------------------------------#
describe "In general" do describe 'In general' do
it "compares to another" do it 'compares to another' do
dependency_1 = Dependency.new("Reachability", :git => 'url') dependency_1 = Dependency.new('Reachability', :git => 'url')
dependency_2 = Dependency.new("Another_name", :git => 'url') dependency_2 = Dependency.new('Another_name', :git => 'url')
dependency_3 = Dependency.new("Reachability", :git => 'another_url') dependency_3 = Dependency.new('Reachability', :git => 'another_url')
dependency_1.should.be == dependency_1 dependency_1.should.be == dependency_1
dependency_1.should.not.be == dependency_2 dependency_1.should.not.be == dependency_2
dependency_1.should.not.be == dependency_3 dependency_1.should.not.be == dependency_3
end end
it "fetches the specification from the remote stores it in the sandbox" do it 'fetches the specification from the remote stores it in the sandbox' do
config.sandbox.specification('Reachability').should == nil config.sandbox.specification('Reachability').should.nil?
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.specification('Reachability').name.should == 'Reachability' config.sandbox.specification('Reachability').name.should == 'Reachability'
end end
...@@ -32,19 +32,19 @@ module Pod ...@@ -32,19 +32,19 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "Subclasses helpers" do describe 'Subclasses helpers' do
it "pre-downloads the Pod and stores the relevant information in the sandbox" do it 'pre-downloads the Pod and stores the relevant information in the sandbox' do
sandbox = config.sandbox sandbox = config.sandbox
@subject.send(:pre_download, sandbox) @subject.send(:pre_download, sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
sandbox.predownloaded_pods.should == ["Reachability"] sandbox.predownloaded_pods.should == ['Reachability']
sandbox.checkout_sources.should == { sandbox.checkout_sources.should == {
"Reachability" => { 'Reachability' => {
:git => fixture('integration/Reachability'), :git => fixture('integration/Reachability'),
:commit => "4ec575e4b074dcc87c44018cce656672a979b34a" :commit => '4ec575e4b074dcc87c44018cce656672a979b34a',
} },
} }
end end
end end
......
...@@ -5,24 +5,24 @@ module Pod ...@@ -5,24 +5,24 @@ module Pod
before do before do
params = { params = {
:git => fixture('integration/Reachability'), :git => fixture('integration/Reachability'),
:branch => 'master' :branch => 'master',
} }
dep = Dependency.new("Reachability", params) dep = Dependency.new('Reachability', params)
@subject = ExternalSources.from_dependency(dep, nil) @subject = ExternalSources.from_dependency(dep, nil)
end end
it "creates a copy of the podspec" do it 'creates a copy of the podspec' do
@subject.fetch(config.sandbox) @subject.fetch(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 the Pod as pre-downloaded" do it 'marks the Pod as pre-downloaded' do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.predownloaded_pods.should == ["Reachability"] config.sandbox.predownloaded_pods.should == ['Reachability']
end end
it "returns the description" do it 'returns the description' do
expected = /from `.*Reachability`, branch `master`/ expected = /from `.*Reachability`, branch `master`/
@subject.description.should.match(expected) @subject.description.should.match(expected)
end end
......
...@@ -6,28 +6,28 @@ module Pod ...@@ -6,28 +6,28 @@ module Pod
@subject = ExternalSources @subject = ExternalSources
end end
describe "from_dependency" do describe 'from_dependency' do
it "supports a podspec source" do it 'supports a podspec source' do
dep = Dependency.new("Reachability", :podspec => nil) dep = Dependency.new('Reachability', :podspec => nil)
klass = @subject.from_dependency(dep, nil).class klass = @subject.from_dependency(dep, nil).class
klass.should == @subject::PodspecSource klass.should == @subject::PodspecSource
end end
it "supports a path source" do it 'supports a path source' do
dep = Dependency.new("Reachability", :path => nil) dep = Dependency.new('Reachability', :path => nil)
klass = @subject.from_dependency(dep, nil).class klass = @subject.from_dependency(dep, nil).class
klass.should == @subject::PathSource klass.should == @subject::PathSource
end end
it "supports a path source specified with the legacy :local key" do it 'supports a path source specified with the legacy :local key' do
dep = Dependency.new("Reachability", :local => nil) dep = Dependency.new('Reachability', :local => nil)
klass = @subject.from_dependency(dep, nil).class klass = @subject.from_dependency(dep, nil).class
klass.should == @subject::PathSource klass.should == @subject::PathSource
end end
it "supports all the strategies implemented by the downloader" do it 'supports all the strategies implemented by the downloader' do
[:git, :svn, :hg, :bzr, :http].each do |strategy| [:git, :svn, :hg, :bzr, :http].each do |strategy|
dep = Dependency.new("Reachability", strategy => nil) dep = Dependency.new('Reachability', strategy => nil)
klass = @subject.from_dependency(dep, nil).class klass = @subject.from_dependency(dep, nil).class
klass.should == @subject::DownloaderSource klass.should == @subject::DownloaderSource
end end
......
require File.expand_path("../../../../spec_helper", __FILE__) require File.expand_path('../../../../spec_helper', __FILE__)
describe Pod::Generator::Markdown do describe Pod::Generator::Markdown do
before do before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = @file_accessor.spec @spec = @file_accessor.spec
@generator = Pod::Generator::Markdown.new([@file_accessor]) @generator = Pod::Generator::Markdown.new([@file_accessor])
@spec.stubs(:name).returns("POD_NAME") @spec.stubs(:name).returns('POD_NAME')
@generator.stubs(:license_text).returns("LICENSE_TEXT") @generator.stubs(:license_text).returns('LICENSE_TEXT')
end end
it "returns a correctly formatted title string" do it 'returns a correctly formatted title string' do
@generator.title_from_string("A Title", 2).should.equal "## A Title" @generator.title_from_string('A Title', 2).should.equal '## A Title'
end end
it "returns a correctly formatted license string for each pod" do it 'returns a correctly formatted license string for each pod' do
@generator.string_for_spec(@spec).should.equal "\n## POD_NAME\n\nLICENSE_TEXT\n" @generator.string_for_spec(@spec).should.equal "\n## POD_NAME\n\nLICENSE_TEXT\n"
end end
it "returns a correctly formatted markdown string for the target" do it 'returns a correctly formatted markdown string for the target' do
@generator.stubs(:header_title).returns("HEADER_TITLE") @generator.stubs(:header_title).returns('HEADER_TITLE')
@generator.stubs(:header_text).returns("HEADER_TEXT") @generator.stubs(:header_text).returns('HEADER_TEXT')
@generator.stubs(:footnote_title).returns("") # Test that extra \n isn't added for empty strings @generator.stubs(:footnote_title).returns('') # Test that extra \n isn't added for empty strings
@generator.stubs(:footnote_text).returns("FOOTNOTE_TEXT") @generator.stubs(:footnote_text).returns('FOOTNOTE_TEXT')
@generator.licenses.should.equal "# HEADER_TITLE\nHEADER_TEXT\n\n## POD_NAME\n\nLICENSE_TEXT\nFOOTNOTE_TEXT\n" @generator.licenses.should.equal "# HEADER_TITLE\nHEADER_TEXT\n\n## POD_NAME\n\nLICENSE_TEXT\nFOOTNOTE_TEXT\n"
end end
it "writes a markdown file to disk" do it 'writes a markdown file to disk' do
basepath = config.sandbox.root + "Pods-acknowledgements" basepath = config.sandbox.root + 'Pods-acknowledgements'
given_path = @generator.class.path_from_basepath(basepath) given_path = @generator.class.path_from_basepath(basepath)
expected_path = config.sandbox.root + "Pods-acknowledgements.markdown" expected_path = config.sandbox.root + 'Pods-acknowledgements.markdown'
mockFile = mock mockFile = mock
mockFile.expects(:write).with(equals(@generator.licenses)) mockFile.expects(:write).with(equals(@generator.licenses))
mockFile.expects(:close) mockFile.expects(:close)
File.expects(:new).with(equals(expected_path), equals("w")).returns(mockFile) File.expects(:new).with(equals(expected_path), equals('w')).returns(mockFile)
@generator.save_as(given_path) @generator.save_as(given_path)
end end
end end
require File.expand_path("../../../../spec_helper", __FILE__) require File.expand_path('../../../../spec_helper', __FILE__)
require 'xcodeproj' require 'xcodeproj'
...@@ -7,43 +7,43 @@ describe Pod::Generator::Plist do ...@@ -7,43 +7,43 @@ describe Pod::Generator::Plist do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@spec = @file_accessor.spec @spec = @file_accessor.spec
@generator = Pod::Generator::Plist.new([@file_accessor]) @generator = Pod::Generator::Plist.new([@file_accessor])
@spec.stubs(:name).returns("POD_NAME") @spec.stubs(:name).returns('POD_NAME')
@generator.stubs(:license_text).returns("LICENSE_TEXT") @generator.stubs(:license_text).returns('LICENSE_TEXT')
end end
it "returns the correct number of licenses (including header and footnote)" do it 'returns the correct number of licenses (including header and footnote)' do
@generator.licenses.count.should == 3 @generator.licenses.count.should == 3
end end
it "returns a string for the plist title" do it 'returns a string for the plist title' do
@generator.plist_title.should.be.kind_of(String) @generator.plist_title.should.be.kind_of(String)
end end
it "returns a correctly formed license hash for each pod" do it 'returns a correctly formed license hash for each pod' do
@generator.hash_for_spec(@spec).should == { @generator.hash_for_spec(@spec).should == {
:Type => "PSGroupSpecifier", :Type => 'PSGroupSpecifier',
:Title => "POD_NAME", :Title => 'POD_NAME',
:FooterText => "LICENSE_TEXT" :FooterText => 'LICENSE_TEXT',
} }
end end
it "returns nil for a pod with no license text" do it 'returns nil for a pod with no license text' do
@generator.expects(:license_text).returns(nil) @generator.expects(:license_text).returns(nil)
@generator.hash_for_spec(@spec).should.be.nil @generator.hash_for_spec(@spec).should.be.nil
end end
it "returns a plist containg the licenses" do it 'returns a plist containg the licenses' do
@generator.plist.should == { @generator.plist.should == {
:Title => "Acknowledgements", :Title => 'Acknowledgements',
:StringsTable => "Acknowledgements", :StringsTable => 'Acknowledgements',
:PreferenceSpecifiers => @generator.licenses :PreferenceSpecifiers => @generator.licenses,
} }
end end
it "writes a plist to disk at the given path" do it 'writes a plist to disk at the given path' do
basepath = config.sandbox.root + "Pods-acknowledgements" basepath = config.sandbox.root + 'Pods-acknowledgements'
given_path = @generator.class.path_from_basepath(basepath) given_path = @generator.class.path_from_basepath(basepath)
expected_path = config.sandbox.root + "Pods-acknowledgements.plist" expected_path = config.sandbox.root + 'Pods-acknowledgements.plist'
Xcodeproj.expects(:write_plist).with(equals(@generator.plist), equals(expected_path)) Xcodeproj.expects(:write_plist).with(equals(@generator.plist), equals(expected_path))
@generator.save_as(given_path) @generator.save_as(given_path)
end end
......
require File.expand_path("../../../spec_helper", __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Generator::Acknowledgements do describe Generator::Acknowledgements do
...@@ -8,14 +8,14 @@ module Pod ...@@ -8,14 +8,14 @@ module Pod
@generator = Pod::Generator::Acknowledgements.new([@file_accessor]) @generator = Pod::Generator::Acknowledgements.new([@file_accessor])
end end
describe "In general" do describe 'In general' do
it "returns the classes of the concrete generators generators" do it 'returns the classes of the concrete generators generators' do
generators = Pod::Generator::Acknowledgements.generators generators = Pod::Generator::Acknowledgements.generators
generators.map { |g| g.name.split('::').last }.should == ['Plist', 'Markdown'] generators.map { |g| g.name.split('::').last }.should == %w(Plist Markdown)
end end
it "returns a string for each header and footnote text method" do it 'returns a string for each header and footnote text method' do
@generator.header_title.should.be.kind_of(String) @generator.header_title.should.be.kind_of(String)
@generator.header_text.should.be.kind_of(String) @generator.header_text.should.be.kind_of(String)
@generator.footnote_title.should.be.kind_of(String) @generator.footnote_title.should.be.kind_of(String)
...@@ -26,28 +26,28 @@ module Pod ...@@ -26,28 +26,28 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "Private methods" do describe 'Private methods' do
it "returns the root specifications" do it 'returns the root specifications' do
generator = Pod::Generator::Acknowledgements.new([@file_accessor, @file_accessor]) generator = Pod::Generator::Acknowledgements.new([@file_accessor, @file_accessor])
generator.send(:specs).should == [@file_accessor.spec] generator.send(:specs).should == [@file_accessor.spec]
end end
it "returns the license" do it 'returns the license' do
text_from_spec = @generator.send(:license_text, @spec) text_from_spec = @generator.send(:license_text, @spec)
text_from_spec.should == "Permission is hereby granted ..." text_from_spec.should == 'Permission is hereby granted ...'
end end
it "returns the license from the file" do it 'returns the license from the file' do
@spec.stubs(:license).returns({ :type => 'MIT', :file => 'README'}) @spec.stubs(:license).returns(:type => 'MIT', :file => 'README')
text_from_spec = @generator.send(:license_text, @spec) text_from_spec = @generator.send(:license_text, @spec)
text_from_spec.should == "post v1.0\n" text_from_spec.should == "post v1.0\n"
end end
it "warns the user if the file specified in the license doesn't exists" do it "warns the user if the file specified in the license doesn't exists" do
@spec.stubs(:license).returns({ :type => 'MIT', :file => 'MISSING'}) @spec.stubs(:license).returns(:type => 'MIT', :file => 'MISSING')
text_from_spec = @generator.send(:license_text, @spec) text_from_spec = @generator.send(:license_text, @spec)
UI.warnings.should.include "Unable to read the license file" UI.warnings.should.include 'Unable to read the license file'
end end
end end
......
...@@ -3,14 +3,14 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,14 +3,14 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Generator::CopyResourcesScript do describe Generator::CopyResourcesScript do
it "returns the copy resources script" do it 'returns the copy resources script' do
resources = ['path/to/resource.png'] resources = ['path/to/resource.png']
generator = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '6.0')) generator = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '6.0'))
generator.send(:script).should.include 'path/to/resource.png' generator.send(:script).should.include 'path/to/resource.png'
generator.send(:script).should.include 'storyboard' generator.send(:script).should.include 'storyboard'
end end
it "instructs ibtool to use the --reference-external-strings-file if set to do so" do it 'instructs ibtool to use the --reference-external-strings-file if set to do so' do
resources = ['path/to/resource.png'] resources = ['path/to/resource.png']
generator_1 = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '4.0')) generator_1 = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '4.0'))
generator_2 = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '6.0')) generator_2 = Pod::Generator::CopyResourcesScript.new(resources, Platform.new(:ios, '6.0'))
......
...@@ -2,8 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::DummySource do describe Pod::Generator::DummySource do
it 'generates a dummy source file with the appropriate class for the class name identifier' do
it "generates a dummy source file with the appropriate class for the class name identifier" do
generator = Pod::Generator::DummySource.new('SomeIdentification') generator = Pod::Generator::DummySource.new('SomeIdentification')
file = temporary_directory + 'PodsDummy.m' file = temporary_directory + 'PodsDummy.m'
generator.save_as(file) generator.save_as(file)
...@@ -16,11 +15,11 @@ describe Pod::Generator::DummySource do ...@@ -16,11 +15,11 @@ describe Pod::Generator::DummySource do
EOS EOS
end end
it "generates a dummy source file with the appropriate class, replacing non-alphanumeric characters with underscores" do it 'generates a dummy source file with the appropriate class, replacing non-alphanumeric characters with underscores' do
generator = Pod::Generator::DummySource.new('This!has_non-alphanumeric+characters in it.0123456789') generator = Pod::Generator::DummySource.new('This!has_non-alphanumeric+characters in it.0123456789')
file = temporary_directory + 'PodsDummy.m' file = temporary_directory + 'PodsDummy.m'
generator.save_as(file) generator.save_as(file)
file.read.should == <<-EOS.strip_heredoc file.read.should == <<-EOS.strip_heredoc
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface PodsDummy_This_has_non_alphanumeric_characters_in_it_0123456789 : NSObject @interface PodsDummy_This_has_non_alphanumeric_characters_in_it_0123456789 : NSObject
@end @end
......
...@@ -42,11 +42,11 @@ module Pod ...@@ -42,11 +42,11 @@ module Pod
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil @spec.prefix_header_file = nil
@spec.subspec 'UI' do |su| @spec.subspec 'UI' do |su|
su.source_files = 'Source/UI/*.{h,m}' su.source_files = 'Source/UI/*.{h,m}'
end end
@spec.subspec 'Helpers' do |sh| @spec.subspec 'Helpers' do |sh|
sh.source_files = 'Source/Helpers/*.{h,m}' sh.source_files = 'Source/Helpers/*.{h,m}'
end end
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
...@@ -68,8 +68,8 @@ module Pod ...@@ -68,8 +68,8 @@ module Pod
EOS EOS
end end
it "includes the imports" do it 'includes the imports' do
@gen.imports << "header.h" @gen.imports << 'header.h'
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__ #ifdef __OBJC__
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
...@@ -80,17 +80,17 @@ module Pod ...@@ -80,17 +80,17 @@ module Pod
EOS EOS
end end
it "imports UIKit in iOS platforms" do it 'imports UIKit in iOS platforms' do
@gen.stubs(:platform).returns(Pod::Platform.ios) @gen.stubs(:platform).returns(Pod::Platform.ios)
@gen.generate.should.include?('#import <UIKit/UIKit.h>') @gen.generate.should.include?('#import <UIKit/UIKit.h>')
end end
it "imports Cocoa for OS X platforms" do it 'imports Cocoa for OS X platforms' do
@gen.stubs(:platform).returns(Pod::Platform.osx) @gen.stubs(:platform).returns(Pod::Platform.osx)
@gen.generate.should.include?('#import <Cocoa/Cocoa.h>') @gen.generate.should.include?('#import <Cocoa/Cocoa.h>')
end end
it "writes the prefix header file to the disk" do it 'writes the prefix header file to the disk' do
path = temporary_directory + 'Test.pch' path = temporary_directory + 'Test.pch'
@gen.save_as(path) @gen.save_as(path)
path.read.should == <<-EOS.strip_heredoc path.read.should == <<-EOS.strip_heredoc
......
...@@ -4,10 +4,10 @@ describe Pod::Generator::TargetEnvironmentHeader do ...@@ -4,10 +4,10 @@ describe Pod::Generator::TargetEnvironmentHeader do
before do before do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
@gen = Pod::Generator::TargetEnvironmentHeader.new({'Debug' => [spec]}) @gen = Pod::Generator::TargetEnvironmentHeader.new('Debug' => [spec])
end end
it "generates a header files which include macro definitions for installed Pods" do it 'generates a header files which include macro definitions for installed Pods' do
file = temporary_directory + 'Pods-environment.h' file = temporary_directory + 'Pods-environment.h'
@gen.save_as(file) @gen.save_as(file)
file.read.should == <<-EOS.strip_heredoc file.read.should == <<-EOS.strip_heredoc
...@@ -28,17 +28,17 @@ describe Pod::Generator::TargetEnvironmentHeader do ...@@ -28,17 +28,17 @@ describe Pod::Generator::TargetEnvironmentHeader do
EOS EOS
end end
it "handles specifications with special characters" do it 'handles specifications with special characters' do
name = @gen.send(:safe_spec_name, 'AppleCoreAudioUtilityClasses@thehtb') name = @gen.send(:safe_spec_name, 'AppleCoreAudioUtilityClasses@thehtb')
name.should == 'AppleCoreAudioUtilityClasses_thehtb' name.should == 'AppleCoreAudioUtilityClasses_thehtb'
end end
it "includes conditional statements for specifications not present in all build configurations" do it 'includes conditional statements for specifications not present in all build configurations' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
debug_spec = stub(:name => 'DebugPod', :version => Pod::Version.new('1.2.3')) debug_spec = stub(:name => 'DebugPod', :version => Pod::Version.new('1.2.3'))
specs_by_configuration = { specs_by_configuration = {
'Debug' => [spec, debug_spec], 'Debug' => [spec, debug_spec],
'Release' => [spec] 'Release' => [spec],
} }
@gen = Pod::Generator::TargetEnvironmentHeader.new(specs_by_configuration) @gen = Pod::Generator::TargetEnvironmentHeader.new(specs_by_configuration)
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
...@@ -69,15 +69,14 @@ describe Pod::Generator::TargetEnvironmentHeader do ...@@ -69,15 +69,14 @@ describe Pod::Generator::TargetEnvironmentHeader do
EOS EOS
end end
it "normalizes the name of the build configuration" do it 'normalizes the name of the build configuration' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
specs_by_configuration = { specs_by_configuration = {
'Debug' => [], 'Debug' => [],
'build configuration copy' => [spec] 'build configuration copy' => [spec],
} }
@gen = Pod::Generator::TargetEnvironmentHeader.new(specs_by_configuration) @gen = Pod::Generator::TargetEnvironmentHeader.new(specs_by_configuration)
@gen.generate.should.include 'BUILD_CONFIGURATION_COPY' @gen.generate.should.include 'BUILD_CONFIGURATION_COPY'
end end
end end
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.whitelist_pod_for_configuration("BananaLib", "Release") target_definition.whitelist_pod_for_configuration('BananaLib', 'Release')
@target = AggregateTarget.new(target_definition, config.sandbox) @target = AggregateTarget.new(target_definition, config.sandbox)
@target.client_root = config.sandbox.root.dirname @target.client_root = config.sandbox.root.dirname
@target.stubs(:platform).returns(:ios) @target.stubs(:platform).returns(:ios)
...@@ -17,10 +17,10 @@ module Pod ...@@ -17,10 +17,10 @@ module Pod
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer]) @pod_target.stubs(:spec_consumers).returns([@consumer])
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
@generator = AggregateXCConfig.new(@target, "Release") @generator = AggregateXCConfig.new(@target, 'Release')
end end
it "returns the path of the pods root relative to the user project" do it 'returns the path of the pods root relative to the user project' do
@generator.target.relative_pods_root.should == '${SRCROOT}/Pods' @generator.target.relative_pods_root.should == '${SRCROOT}/Pods'
end end
...@@ -32,27 +32,27 @@ module Pod ...@@ -32,27 +32,27 @@ module Pod
@xcconfig = @generator.generate @xcconfig = @generator.generate
end end
it "generates the xcconfig" do it 'generates the xcconfig' do
@xcconfig.class.should == Xcodeproj::Config @xcconfig.class.should == Xcodeproj::Config
end end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do it 'configures the project to load all members that implement Objective-c classes or categories from the static library' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true) @consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc") @xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include('-fobjc-arc')
end end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true) @podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true) @consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc") @xcconfig.to_hash['OTHER_LDFLAGS'].split(' ').should.include('-fobjc-arc')
end end
it "sets the PODS_ROOT build variable" do it 'sets the PODS_ROOT build variable' do
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods' @xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end end
...@@ -74,12 +74,12 @@ module Pod ...@@ -74,12 +74,12 @@ module Pod
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)' @xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)'
end end
it "links the pod targets with the aggregate integration library target" do it 'links the pod targets with the aggregate integration library target' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-l "Pods-BananaLib"' @xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-l "Pods-BananaLib"'
end end
it "does not links the pod targets with the aggregate integration library target for non-whitelisted configuration" do it 'does not links the pod targets with the aggregate integration library target for non-whitelisted configuration' do
@generator = AggregateXCConfig.new(@target, "Debug") @generator = AggregateXCConfig.new(@target, 'Debug')
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-lPods-BananaLib' @xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-lPods-BananaLib'
end end
...@@ -91,7 +91,7 @@ module Pod ...@@ -91,7 +91,7 @@ module Pod
@generator.save_as(@path) @generator.save_as(@path)
end end
it "saves the xcconfig" do it 'saves the xcconfig' do
generated = Xcodeproj::Config.new(@path) generated = Xcodeproj::Config.new(@path)
generated.class.should == Xcodeproj::Config generated.class.should == Xcodeproj::Config
end end
......
...@@ -5,42 +5,42 @@ module Pod ...@@ -5,42 +5,42 @@ module Pod
module XCConfig module XCConfig
describe PrivatePodXCConfig do describe PrivatePodXCConfig do
describe "in general" do describe 'in general' do
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
public_xcconfig = Xcodeproj::Config.new({"OTHER_LDFLAGS"=>"-framework SystemConfiguration"}) public_xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework SystemConfiguration')
@generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig) @generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig)
@podfile = Podfile.new @podfile = Podfile.new
@pod_target.target_definition.stubs(:podfile).returns(@podfile) @pod_target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate @xcconfig = @generator.generate
end end
it "generates the xcconfig" do it 'generates the xcconfig' do
@xcconfig.class.should == Xcodeproj::Config @xcconfig.class.should == Xcodeproj::Config
end end
it "configures the project to load all members that implement Objective-c classes or categories from the static library" do it 'configures the project to load all members that implement Objective-c classes or categories from the static library' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
@consumer.stubs(:requires_arc?).returns(true) @consumer.stubs(:requires_arc?).returns(true)
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include("-fobjc-arc") @xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include('-fobjc-arc')
end end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it' do
@podfile.stubs(:set_arc_compatibility_flag?).returns(true) @podfile.stubs(:set_arc_compatibility_flag?).returns(true)
@consumer.stubs(:requires_arc?).returns(true) @consumer.stubs(:requires_arc?).returns(true)
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc") @xcconfig.to_hash['OTHER_LDFLAGS'].split(' ').should.include('-fobjc-arc')
end end
it "sets the PODS_ROOT build variable" do it 'sets the PODS_ROOT build variable' do
@xcconfig.to_hash['PODS_ROOT'].should.not == nil @xcconfig.to_hash['PODS_ROOT'].should.not.nil?
end end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
...@@ -63,7 +63,7 @@ module Pod ...@@ -63,7 +63,7 @@ module Pod
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}' @xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}'
end end
it "saves the xcconfig" do it 'saves the xcconfig' do
path = temporary_directory + 'sample.xcconfig' path = temporary_directory + 'sample.xcconfig'
@generator.save_as(path) @generator.save_as(path)
generated = Xcodeproj::Config.new(path) generated = Xcodeproj::Config.new(path)
...@@ -74,33 +74,33 @@ module Pod ...@@ -74,33 +74,33 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private Helpers" do describe 'Private Helpers' do
before do before do
@sut = PrivatePodXCConfig.new(stub(), stub()) @sut = PrivatePodXCConfig.new(stub, stub)
end end
#----------------------------------------# #----------------------------------------#
describe "#add_xcconfig_namespaced_keys" do describe '#add_xcconfig_namespaced_keys' do
it "appends to the values of the keys of the destination the value of the keys of the source" do it 'appends to the values of the keys of the destination the value of the keys of the source' do
source_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/MyPod' } source_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/MyPod' }
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' } destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_') result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders ${PREFIX_HEADER_SEARCH_PATHS}' } result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders ${PREFIX_HEADER_SEARCH_PATHS}' }
end end
it "uses the key of the destination xcconfig if not present in the source" do it 'uses the key of the destination xcconfig if not present in the source' do
source_config = { } source_config = {}
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' } destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_') result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' } result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
end end
it "preserves any value of the source not present in the destination" do it 'preserves any value of the source not present in the destination' do
source_config = { 'EXCLUDED_SOURCE_FILE_NAMES' => 'ZBarReaderViewImpl_Simulator.m' } source_config = { 'EXCLUDED_SOURCE_FILE_NAMES' => 'ZBarReaderViewImpl_Simulator.m' }
destination_config = { } destination_config = {}
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_') result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'EXCLUDED_SOURCE_FILE_NAMES' => '${PREFIX_EXCLUDED_SOURCE_FILE_NAMES}' } result.should == { 'EXCLUDED_SOURCE_FILE_NAMES' => '${PREFIX_EXCLUDED_SOURCE_FILE_NAMES}' }
end end
...@@ -109,14 +109,14 @@ module Pod ...@@ -109,14 +109,14 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#conditional_less_key" do describe '#conditional_less_key' do
it "returns the key without the xcconfig conditional syntax if present" do it 'returns the key without the xcconfig conditional syntax if present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]') result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES' result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end end
it "returns the key as it is if no conditional syntax is present" do it 'returns the key as it is if no conditional syntax is present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES') result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES' result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end end
......
...@@ -27,27 +27,27 @@ module Pod ...@@ -27,27 +27,27 @@ module Pod
@xcconfig = @generator.generate @xcconfig = @generator.generate
end end
it "generates the xcconfig" do it 'generates the xcconfig' do
@xcconfig.class.should == Xcodeproj::Config @xcconfig.class.should == Xcodeproj::Config
end end
it "includes the xcconfig of the specifications" do it 'includes the xcconfig of the specifications' do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include('-no_compact_unwind') @xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-no_compact_unwind')
end end
it "includes the libraries for the specifications" do it 'includes the libraries for the specifications' do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include(%q(-l "xml2")) @xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-l "xml2"')
end end
it "includes the frameworks of the specifications" do it 'includes the frameworks of the specifications' do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include(%q(-framework "QuartzCore")) @xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-framework "QuartzCore"')
end end
it "includes the weak-frameworks of the specifications" do it 'includes the weak-frameworks of the specifications' do
@xcconfig.to_hash["OTHER_LDFLAGS"].should.include(%q(-weak_framework "iAd")) @xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework "iAd"')
end end
it "includes the developer frameworks search paths when SenTestingKit is detected" do it 'includes the developer frameworks search paths when SenTestingKit is detected' do
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @generator.generate
...@@ -60,20 +60,20 @@ module Pod ...@@ -60,20 +60,20 @@ module Pod
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @generator.generate
framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].split(' ') framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].split(' ')
framework_search_paths.select { |path| path == '"$(SDKROOT)/Developer/Library/Frameworks"'}.count.should == 1 framework_search_paths.select { |path| path == '"$(SDKROOT)/Developer/Library/Frameworks"' }.count.should == 1
framework_search_paths.select { |path| path == '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'}.count.should == 1 framework_search_paths.select { |path| path == '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"' }.count.should == 1
end end
it "includes the build settings of the frameworks bundles of the spec" do it 'includes the build settings of the frameworks bundles of the spec' do
config.sandbox.stubs(:root).returns(fixture('')) config.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
it "includes the build settings of the libraries shipped with the spec" do it 'includes the build settings of the libraries shipped with the spec' do
config.sandbox.stubs(:root).returns(fixture('')) config.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash['LIBRARY_SEARCH_PATHS'].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -83,14 +83,14 @@ module Pod ...@@ -83,14 +83,14 @@ module Pod
@generator.save_as(@path) @generator.save_as(@path)
end end
it "saves the xcconfig" do it 'saves the xcconfig' do
generated = Xcodeproj::Config.new(@path) generated = Xcodeproj::Config.new(@path)
generated.class.should == Xcodeproj::Config generated.class.should == Xcodeproj::Config
end end
it "writes the xcconfig with a prefix computed from the target definition and root spec" do it 'writes the xcconfig with a prefix computed from the target definition and root spec' do
generated = Xcodeproj::Config.new(@path) generated = Xcodeproj::Config.new(@path)
generated.to_hash.each { |k, v| k.should.start_with(@pod_target.xcconfig_prefix) } generated.to_hash.each { |k, _v| k.should.start_with(@pod_target.xcconfig_prefix) }
end end
end end
......
...@@ -11,20 +11,20 @@ module Pod ...@@ -11,20 +11,20 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::default_ld_flags" do describe '::default_ld_flags' do
it "returns the default linker flags" do it 'returns the default linker flags' do
podfile = stub( :set_arc_compatibility_flag? => false ) podfile = stub(:set_arc_compatibility_flag? => false)
target_definition = stub( :podfile => podfile ) target_definition = stub(:podfile => podfile)
target = stub( :target_definition => target_definition ) target = stub(:target_definition => target_definition)
result = @sut.default_ld_flags(target) result = @sut.default_ld_flags(target)
result.should == '-ObjC' result.should == '-ObjC'
end end
it "includes the ARC compatibility flag if required by the Podfile" do it 'includes the ARC compatibility flag if required by the Podfile' do
podfile = stub( :set_arc_compatibility_flag? => true ) podfile = stub(:set_arc_compatibility_flag? => true)
target_definition = stub( :podfile => podfile ) target_definition = stub(:podfile => podfile)
spec_consumer = stub( :requires_arc? => true ) spec_consumer = stub(:requires_arc? => true)
target = stub( :target_definition => target_definition, :spec_consumers => [spec_consumer] ) target = stub(:target_definition => target_definition, :spec_consumers => [spec_consumer])
result = @sut.default_ld_flags(target) result = @sut.default_ld_flags(target)
result.should == '-ObjC -fobjc-arc' result.should == '-ObjC -fobjc-arc'
end end
...@@ -32,96 +32,96 @@ module Pod ...@@ -32,96 +32,96 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::quote" do describe '::quote' do
it "quotes strings" do it 'quotes strings' do
result = @sut.quote(['string1', 'string2']) result = @sut.quote(%w(string1 string2))
result.should == '"string1" "string2"' result.should == '"string1" "string2"'
end end
it "inserts an optional string and then the normal quoted string" do it 'inserts an optional string and then the normal quoted string' do
result = @sut.quote(['string1', 'string2'], '-isystem') result = @sut.quote(%w(string1 string2), '-isystem')
result.should == '-isystem "string1" -isystem "string2"' result.should == '-isystem "string1" -isystem "string2"'
end end
end end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::add_spec_build_settings_to_xcconfig" do describe '::add_spec_build_settings_to_xcconfig' do
it "adds the build settings of the consumer" do it 'adds the build settings of the consumer' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => { 'OTHER_LDFLAGS' => '-framework SenTestingKit' }, :xcconfig => { 'OTHER_LDFLAGS' => '-framework SenTestingKit' },
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == %q(-framework "SenTestingKit") xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "SenTestingKit"'
end end
it "adds the libraries of the xcconfig" do it 'adds the libraries of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => {}, :xcconfig => {},
:libraries => ['xml2'], :libraries => ['xml2'],
:frameworks => [], :frameworks => [],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == %q(-l "xml2") xcconfig.to_hash['OTHER_LDFLAGS'].should == '-l "xml2"'
end end
it "adds the frameworks of the xcconfig" do it 'adds the frameworks of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => {}, :xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['CoreAnimation'], :frameworks => ['CoreAnimation'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == %q(-framework "CoreAnimation") xcconfig.to_hash['OTHER_LDFLAGS'].should == '-framework "CoreAnimation"'
end end
it "adds the weak frameworks of the xcconfig" do it 'adds the weak frameworks of the xcconfig' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => {}, :xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => [], :frameworks => [],
:weak_frameworks => ['iAd'], :weak_frameworks => ['iAd'],
:platform_name => :ios :platform_name => :ios
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['OTHER_LDFLAGS'].should == %q(-weak_framework "iAd") xcconfig.to_hash['OTHER_LDFLAGS'].should == '-weak_framework "iAd"'
end end
it "adds the ios developer frameworks search paths if needed" do it 'adds the ios developer frameworks search paths if needed' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => {}, :xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :ios :platform_name => :ios
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('SDKROOT') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('SDKROOT')
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('DEVELOPER_LIBRARY_DIR') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('DEVELOPER_LIBRARY_DIR')
end end
it "adds the osx developer frameworks search paths if needed" do it 'adds the osx developer frameworks search paths if needed' do
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
consumer = stub({ consumer = stub(
:xcconfig => {}, :xcconfig => {},
:libraries => [], :libraries => [],
:frameworks => ['SenTestingKit'], :frameworks => ['SenTestingKit'],
:weak_frameworks => [], :weak_frameworks => [],
:platform_name => :osx :platform_name => :osx
}) )
@sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig) @sut.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('DEVELOPER_LIBRARY_DIR') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.include('DEVELOPER_LIBRARY_DIR')
xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('SDKROOT') xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].should.not.include('SDKROOT')
...@@ -130,27 +130,27 @@ module Pod ...@@ -130,27 +130,27 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::add_framework_build_settings" do describe '::add_framework_build_settings' do
it "adds the build settings of a framework to the given xcconfig" do it 'adds the build settings of a framework to the given xcconfig' do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == %q(-framework "Parse") hash_config['OTHER_LDFLAGS'].should == '-framework "Parse"'
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"'
end end
it "doesn't ovverides exiting linker flags" do it "doesn't ovverides exiting linker flags" do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'OTHER_LDFLAGS' => '-framework CoreAnimation' } ) xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework CoreAnimation')
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == %q(-framework "CoreAnimation" -framework "Parse") hash_config['OTHER_LDFLAGS'].should == '-framework "CoreAnimation" -framework "Parse"'
end end
it "doesn't ovverides exiting frameworks search paths" do it "doesn't ovverides exiting frameworks search paths" do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"' } ) xcconfig = Xcodeproj::Config.new('FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"')
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"'
...@@ -159,22 +159,22 @@ module Pod ...@@ -159,22 +159,22 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::add_library_build_settings" do describe '::add_library_build_settings' do
it "adds the build settings of a framework to the given xcconfig" do it 'adds the build settings of a framework to the given xcconfig' do
path = config.sandbox.root + 'MapBox/Proj4/libProj4.a' path = config.sandbox.root + 'MapBox/Proj4/libProj4.a'
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_library_build_settings(path, xcconfig, config.sandbox.root) @sut.add_library_build_settings(path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == %q(-l "Proj4") hash_config['OTHER_LDFLAGS'].should == '-l "Proj4"'
hash_config['LIBRARY_SEARCH_PATHS'].should == '"$(PODS_ROOT)/MapBox/Proj4"' hash_config['LIBRARY_SEARCH_PATHS'].should == '"$(PODS_ROOT)/MapBox/Proj4"'
end end
end end
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::add_framework_build_settings" do describe '::add_framework_build_settings' do
it "adds the developer frameworks search paths to the xcconfig if SenTestingKit has been detected" do it 'adds the developer frameworks search paths to the xcconfig if SenTestingKit has been detected' do
xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework SenTestingKit'}) xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework SenTestingKit')
@sut.add_developers_frameworks_if_needed(xcconfig, :ios) @sut.add_developers_frameworks_if_needed(xcconfig, :ios)
frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'] frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
frameworks_search_paths.should.include?('$(inherited)') frameworks_search_paths.should.include?('$(inherited)')
...@@ -182,8 +182,8 @@ module Pod ...@@ -182,8 +182,8 @@ module Pod
frameworks_search_paths.should.not.include?('"$(DEVELOPER_LIBRARY_DIR)/Frameworks"') frameworks_search_paths.should.not.include?('"$(DEVELOPER_LIBRARY_DIR)/Frameworks"')
end end
it "adds the developer frameworks search paths to the xcconfig if XCTest has been detected" do it 'adds the developer frameworks search paths to the xcconfig if XCTest has been detected' do
xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework XCTest'}) xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework XCTest')
@sut.add_developers_frameworks_if_needed(xcconfig, :ios) @sut.add_developers_frameworks_if_needed(xcconfig, :ios)
frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'] frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
frameworks_search_paths.should.include?('$(inherited)') frameworks_search_paths.should.include?('$(inherited)')
...@@ -194,13 +194,12 @@ module Pod ...@@ -194,13 +194,12 @@ module Pod
end end
it "doesn't adds the developer frameworks relative to the SDK for OS X" do it "doesn't adds the developer frameworks relative to the SDK for OS X" do
xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework XCTest'}) xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework XCTest')
@sut.add_developers_frameworks_if_needed(xcconfig, :ios) @sut.add_developers_frameworks_if_needed(xcconfig, :ios)
frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'] frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
frameworks_search_paths.should.include?('"$(SDKROOT)/Developer/Library/Frameworks"') frameworks_search_paths.should.include?('"$(SDKROOT)/Developer/Library/Frameworks"')
xcconfig = Xcodeproj::Config.new('OTHER_LDFLAGS' => '-framework XCTest')
xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework XCTest'})
@sut.add_developers_frameworks_if_needed(xcconfig, :osx) @sut.add_developers_frameworks_if_needed(xcconfig, :osx)
frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'] frameworks_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
frameworks_search_paths.should.not.include?('"$(SDKROOT)/Developer/Library/Frameworks"') frameworks_search_paths.should.not.include?('"$(SDKROOT)/Developer/Library/Frameworks"')
......
...@@ -23,34 +23,34 @@ module Pod ...@@ -23,34 +23,34 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Public Hooks API" do describe 'Public Hooks API' do
it "returns the sandbox root" do it 'returns the sandbox root' do
@rep.sandbox_root.should == config.sandbox.root @rep.sandbox_root.should == config.sandbox.root
end end
it "returns the pods project" do it 'returns the pods project' do
project = stub() project = stub
safe_stub(@installer, :pods_project, project) safe_stub(@installer, :pods_project, project)
@rep.project.should == project @rep.project.should == project
end end
it "the hook representation of the pods" do it 'the hook representation of the pods' do
@rep.pods.map(&:name).should == ['JSONKit'] @rep.pods.map(&:name).should == ['JSONKit']
end end
it "the hook representation of the libraries" do it 'the hook representation of the libraries' do
@rep.libraries.map(&:name).sort.should == ['Pods'].sort @rep.libraries.map(&:name).sort.should == ['Pods'].sort
end end
it "returns the specs by library representation" do it 'returns the specs by library representation' do
specs_by_lib = @rep.specs_by_lib specs_by_lib = @rep.specs_by_lib
lib_rep = specs_by_lib.keys.first lib_rep = specs_by_lib.keys.first
lib_rep.name.should == 'Pods' lib_rep.name.should == 'Pods'
specs_by_lib.should == { lib_rep => @specs } specs_by_lib.should == { lib_rep => @specs }
end end
it "returns the pods representation by library representation" do it 'returns the pods representation by library representation' do
pods_by_lib = @rep.pods_by_lib pods_by_lib = @rep.pods_by_lib
target_definition = @installer.aggregate_targets.first.pod_targets.first.target_definition target_definition = @installer.aggregate_targets.first.pod_targets.first.target_definition
pods_by_lib[target_definition].map(&:name).should == ['JSONKit'] pods_by_lib[target_definition].map(&:name).should == ['JSONKit']
...@@ -60,17 +60,17 @@ module Pod ...@@ -60,17 +60,17 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Unsafe Hooks API" do describe 'Unsafe Hooks API' do
it "returns the sandbox" do it 'returns the sandbox' do
@rep.sandbox.should == config.sandbox @rep.sandbox.should == config.sandbox
end end
it "returns the config" do it 'returns the config' do
@rep.config.should == config @rep.config.should == config
end end
it "returns the installer" do it 'returns the installer' do
@rep.installer.should == @installer @rep.installer.should == @installer
end end
......
...@@ -13,36 +13,36 @@ module Pod ...@@ -13,36 +13,36 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Public Hooks API" do describe 'Public Hooks API' do
it "returns the name" do it 'returns the name' do
@rep.name.should == 'Pods-MyApp' @rep.name.should == 'Pods-MyApp'
end end
it "returns the dependencies" do it 'returns the dependencies' do
@target_definition.store_pod('AFNetworking') @target_definition.store_pod('AFNetworking')
@rep.dependencies.should == [Dependency.new('AFNetworking')] @rep.dependencies.should == [Dependency.new('AFNetworking')]
end end
it "returns the sandbox dir" do it 'returns the sandbox dir' do
@rep.sandbox_dir.should == temporary_directory + 'Pods' @rep.sandbox_dir.should == temporary_directory + 'Pods'
end end
it "returns the path of the prefix header" do it 'returns the path of the prefix header' do
@rep.prefix_header_path.should == temporary_directory + 'Pods/Pods-MyApp-prefix.pch' @rep.prefix_header_path.should == temporary_directory + 'Pods/Pods-MyApp-prefix.pch'
end end
it "returns the path of the copy resources script" do it 'returns the path of the copy resources script' do
@rep.copy_resources_script_path.should == temporary_directory + 'Pods/Pods-MyApp-resources.sh' @rep.copy_resources_script_path.should == temporary_directory + 'Pods/Pods-MyApp-resources.sh'
end end
it "returns the pods project" do it 'returns the pods project' do
project = stub() project = stub
config.sandbox.project = project config.sandbox.project = project
@rep.project.should == project @rep.project.should == project
end end
it "returns the target definition" do it 'returns the target definition' do
@rep.target_definition.should == @target_definition @rep.target_definition.should == @target_definition
end end
...@@ -50,18 +50,18 @@ module Pod ...@@ -50,18 +50,18 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Unsafe Hooks API" do describe 'Unsafe Hooks API' do
it "returns the sandbox" do it 'returns the sandbox' do
@rep.sandbox.should == config.sandbox @rep.sandbox.should == config.sandbox
end end
it "returns the library" do it 'returns the library' do
@rep.library.should == @lib @rep.library.should == @lib
end end
it "returns the native target" do it 'returns the native target' do
target = stub() target = stub
@lib.target = target @lib.target = target
@rep.target.should == target @rep.target.should == target
end end
......
...@@ -12,38 +12,35 @@ module Pod ...@@ -12,38 +12,35 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Public Hooks API" do describe 'Public Hooks API' do
it "returns the name" do it 'returns the name' do
@rep.name.should == 'BananaLib' @rep.name.should == 'BananaLib'
end end
it "returns the version" do it 'returns the version' do
@rep.version.should == Version.new('1.0') @rep.version.should == Version.new('1.0')
end end
it 'returns the root specification' do
it "returns the root specification" do
@rep.root_spec.should == @spec @rep.root_spec.should == @spec
end end
it 'returns all the activated specifications' do
it "returns all the activated specifications" do
@rep.specs.should == [@spec] @rep.specs.should == [@spec]
end end
it 'returns the directory where the pod is stored' do
it "returns the directory where the pod is stored" do
@rep.root.should == @root @rep.root.should == @root
end end
it "returns the source files" do it 'returns the source files' do
source_files = @rep.source_files.map{ |sf| sf.relative_path_from(@root).to_s }.sort source_files = @rep.source_files.map { |sf| sf.relative_path_from(@root).to_s }.sort
source_files.should == [ source_files.should == [
"Classes/Banana.h", 'Classes/Banana.h',
"Classes/Banana.m", 'Classes/Banana.m',
"Classes/BananaPrivate.h", 'Classes/BananaPrivate.h',
"Classes/BananaTrace.d" 'Classes/BananaTrace.d',
] ]
end end
......
...@@ -7,19 +7,19 @@ module Pod ...@@ -7,19 +7,19 @@ module Pod
end end
describe 'register' do describe 'register' do
it "allows to register a block for a notification with a given name" do it 'allows to register a block for a notification with a given name' do
@hooks_manager.register(:post_install) {} @hooks_manager.register(:post_install) {}
@hooks_manager.registrations[:post_install].count.should == 1 @hooks_manager.registrations[:post_install].count.should == 1
@hooks_manager.registrations[:post_install].first.class.should == Proc @hooks_manager.registrations[:post_install].first.class.should == Proc
end end
it "raises if no name is given" do it 'raises if no name is given' do
should.raise ArgumentError do should.raise ArgumentError do
@hooks_manager.register(nil) {} @hooks_manager.register(nil) {}
end end
end end
it "raises if no block is given" do it 'raises if no block is given' do
should.raise ArgumentError do should.raise ArgumentError do
@hooks_manager.register(:post_install) @hooks_manager.register(:post_install)
end end
...@@ -27,21 +27,21 @@ module Pod ...@@ -27,21 +27,21 @@ module Pod
end end
describe 'run' do describe 'run' do
it "invokes the hooks" do it 'invokes the hooks' do
@hooks_manager.register(:post_install) do |options| @hooks_manager.register(:post_install) do |_options|
true.should.be.true true.should.be.true
end end
@hooks_manager.run(:post_install, Object.new) @hooks_manager.run(:post_install, Object.new)
end end
it "handles the case that no listeners have registered" do it 'handles the case that no listeners have registered' do
should.not.raise do should.not.raise do
@hooks_manager.run(:post_install, Object.new) @hooks_manager.run(:post_install, Object.new)
end end
end end
it "handles the case that no listeners have registered for a name" do it 'handles the case that no listeners have registered for a name' do
@hooks_manager.register(:post_install) do |options| @hooks_manager.register(:post_install) do |_options|
true.should.be.true true.should.be.true
end end
should.not.raise do should.not.raise do
...@@ -49,13 +49,13 @@ module Pod ...@@ -49,13 +49,13 @@ module Pod
end end
end end
it "raises if no name is given" do it 'raises if no name is given' do
should.raise ArgumentError do should.raise ArgumentError do
@hooks_manager.run(nil, Object.new) {} @hooks_manager.run(nil, Object.new) {}
end end
end end
it "raises if no context object is given" do it 'raises if no context object is given' do
should.raise ArgumentError do should.raise ArgumentError do
@hooks_manager.run(:post_install, nil) @hooks_manager.run(:post_install, nil)
end end
...@@ -63,4 +63,3 @@ module Pod ...@@ -63,4 +63,3 @@ module Pod
end end
end end
end end
...@@ -16,18 +16,18 @@ module Pod ...@@ -16,18 +16,18 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Analysis" do describe 'Analysis' do
it "returns the sandbox state" do it 'returns the sandbox state' do
@analyzer.stubs(:folder_exist?).returns(true) @analyzer.stubs(:folder_exist?).returns(true)
@analyzer.stubs(:folder_empty?).returns(false) @analyzer.stubs(:folder_empty?).returns(false)
@analyzer.stubs(:sandbox_checksum).returns(@spec.checksum) @analyzer.stubs(:sandbox_checksum).returns(@spec.checksum)
state = @analyzer.analyze state = @analyzer.analyze
state.class.should == Installer::Analyzer::SpecsState state.class.should == Installer::Analyzer::SpecsState
state.unchanged.should == ["BananaLib"] state.unchanged.should == ['BananaLib']
end end
it "marks all the pods as added if no sandbox manifest is available" do it 'marks all the pods as added if no sandbox manifest is available' do
@sandbox.stubs(:manifest) @sandbox.stubs(:manifest)
@analyzer.analyze.added.should == ['BananaLib'] @analyzer.analyze.added.should == ['BananaLib']
end end
...@@ -36,7 +36,7 @@ module Pod ...@@ -36,7 +36,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Analysis" do describe 'Analysis' do
before do before do
@analyzer.stubs(:folder_exist?).returns(true) @analyzer.stubs(:folder_exist?).returns(true)
...@@ -44,11 +44,11 @@ module Pod ...@@ -44,11 +44,11 @@ module Pod
@analyzer.stubs(:sandbox_checksum).returns(@spec.checksum) @analyzer.stubs(:sandbox_checksum).returns(@spec.checksum)
end end
it "returns whether a Pod is unchanged" do it 'returns whether a Pod is unchanged' do
@analyzer.send(:pod_state, 'BananaLib').should == :unchanged @analyzer.send(:pod_state, 'BananaLib').should == :unchanged
end end
it "considers a Pod as added if it is not recorded in the sandbox manifest" do it 'considers a Pod as added if it is not recorded in the sandbox manifest' do
@analyzer.stubs(:sandbox_pods).returns([]) @analyzer.stubs(:sandbox_pods).returns([])
@analyzer.send(:pod_added?, 'BananaLib').should == true @analyzer.send(:pod_added?, 'BananaLib').should == true
end end
...@@ -58,32 +58,32 @@ module Pod ...@@ -58,32 +58,32 @@ module Pod
@analyzer.send(:pod_added?, 'BananaLib').should == true @analyzer.send(:pod_added?, 'BananaLib').should == true
end end
it "considers deleted a Pod without any resolved specification" do it 'considers deleted a Pod without any resolved specification' do
@analyzer.stubs(:resolved_pods).returns([]) @analyzer.stubs(:resolved_pods).returns([])
@analyzer.send(:pod_deleted?, 'BananaLib').should == true @analyzer.send(:pod_deleted?, 'BananaLib').should == true
end end
it "considers changed a Pod whose versions do not match" do it 'considers changed a Pod whose versions do not match' do
@analyzer.stubs(:sandbox_version).returns(Version.new(999)) @analyzer.stubs(:sandbox_version).returns(Version.new(999))
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod whose checksums do not match" do it 'considers changed a Pod whose checksums do not match' do
@analyzer.stubs(:sandbox_checksum).returns('SHA') @analyzer.stubs(:sandbox_checksum).returns('SHA')
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod whose activated specifications do not match" do it 'considers changed a Pod whose activated specifications do not match' do
@analyzer.stubs(:sandbox_spec_names).returns(['BananaLib', 'BananaLib/Subspec']) @analyzer.stubs(:sandbox_spec_names).returns(['BananaLib', 'BananaLib/Subspec'])
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod whose folder is empty" do it 'considers changed a Pod whose folder is empty' do
@analyzer.stubs(:folder_empty?).returns(true) @analyzer.stubs(:folder_empty?).returns(true)
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod which has been pre-downloaded" do it 'considers changed a Pod which has been pre-downloaded' do
@sandbox.stubs(:predownloaded?).returns(true) @sandbox.stubs(:predownloaded?).returns(true)
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
...@@ -93,7 +93,7 @@ module Pod ...@@ -93,7 +93,7 @@ module Pod
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
end end
it "considers changed a Pod whose specification is in head mode if in update mode" do it 'considers changed a Pod whose specification is in head mode if in update mode' do
@sandbox.stubs(:head_pod?).returns(true) @sandbox.stubs(:head_pod?).returns(true)
@analyzer.stubs(:update_mode?).returns(true) @analyzer.stubs(:update_mode?).returns(true)
@analyzer.send(:pod_changed?, 'BananaLib').should == true @analyzer.send(:pod_changed?, 'BananaLib').should == true
...@@ -110,13 +110,13 @@ module Pod ...@@ -110,13 +110,13 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private helpers" do describe 'Private helpers' do
it "returns the sandbox manifest" do it 'returns the sandbox manifest' do
@analyzer.send(:sandbox_manifest).should == @manifest @analyzer.send(:sandbox_manifest).should == @manifest
end end
it "returns the lockfile as the sandbox if one is not available" do it 'returns the lockfile as the sandbox if one is not available' do
lockfile = Lockfile.new({}) lockfile = Lockfile.new({})
@sandbox.stubs(:manifest) @sandbox.stubs(:manifest)
@analyzer.stubs(:lockfile).returns(lockfile) @analyzer.stubs(:lockfile).returns(lockfile)
...@@ -125,29 +125,29 @@ module Pod ...@@ -125,29 +125,29 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "returns the root name of the resolved Pods" do it 'returns the root name of the resolved Pods' do
subspec = Spec.new(@spec, 'Subspec') subspec = Spec.new(@spec, 'Subspec')
@analyzer.stubs(:specs).returns([@spec, subspec]) @analyzer.stubs(:specs).returns([@spec, subspec])
@analyzer.send(:resolved_pods).should == ['BananaLib'] @analyzer.send(:resolved_pods).should == ['BananaLib']
end end
it "returns the root name of pods stored in the sandbox manifest" do it 'returns the root name of pods stored in the sandbox manifest' do
@manifest.stubs(:pod_names).returns(['BananaLib', 'BananaLib/Subspec']) @manifest.stubs(:pod_names).returns(['BananaLib', 'BananaLib/Subspec'])
@analyzer.send(:sandbox_pods).should == ['BananaLib'] @analyzer.send(:sandbox_pods).should == ['BananaLib']
end end
it "returns the name of the resolved specifications sorted by name" do it 'returns the name of the resolved specifications sorted by name' do
subspec = Spec.new(@spec, 'Subspec') subspec = Spec.new(@spec, 'Subspec')
@analyzer.stubs(:specs).returns([subspec, @spec]) @analyzer.stubs(:specs).returns([subspec, @spec])
@analyzer.send(:resolved_spec_names, 'BananaLib').should == ['BananaLib', 'BananaLib/Subspec'] @analyzer.send(:resolved_spec_names, 'BananaLib').should == ['BananaLib', 'BananaLib/Subspec']
end end
it "returns the name of the specifications stored in the sandbox manifest" do it 'returns the name of the specifications stored in the sandbox manifest' do
@manifest.stubs(:pod_names).returns(['BananaLib', 'BananaLib/Subspec']) @manifest.stubs(:pod_names).returns(['BananaLib', 'BananaLib/Subspec'])
@analyzer.send(:sandbox_spec_names, 'BananaLib').should == ['BananaLib', 'BananaLib/Subspec'] @analyzer.send(:sandbox_spec_names, 'BananaLib').should == ['BananaLib', 'BananaLib/Subspec']
end end
it "returns the root specification for the Pod with the given name" do it 'returns the root specification for the Pod with the given name' do
subspec = Spec.new(@spec, 'Subspec') subspec = Spec.new(@spec, 'Subspec')
@analyzer.stubs(:specs).returns([@spec, subspec]) @analyzer.stubs(:specs).returns([@spec, subspec])
@analyzer.send(:root_spec, 'BananaLib').should == @spec @analyzer.send(:root_spec, 'BananaLib').should == @spec
...@@ -155,18 +155,18 @@ module Pod ...@@ -155,18 +155,18 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "returns the version for the Pod with the given name stored in the manifest" do it 'returns the version for the Pod with the given name stored in the manifest' do
@analyzer.send(:sandbox_version, 'BananaLib').should == Version.new('1.0') @analyzer.send(:sandbox_version, 'BananaLib').should == Version.new('1.0')
end end
it "returns the checksum for the spec of the Pods with the given name stored in the manifest" do it 'returns the checksum for the spec of the Pods with the given name stored in the manifest' do
@manifest.stubs(:checksum).returns(@spec.checksum) @manifest.stubs(:checksum).returns(@spec.checksum)
@analyzer.send(:sandbox_checksum, 'BananaLib').should == @spec.checksum @analyzer.send(:sandbox_checksum, 'BananaLib').should == @spec.checksum
end end
#--------------------------------------# #--------------------------------------#
it "returns whether the folder containing the Pod with the given name is empty" do it 'returns whether the folder containing the Pod with the given name is empty' do
@analyzer.send(:folder_exist?, 'BananaLib').should.be.false @analyzer.send(:folder_exist?, 'BananaLib').should.be.false
path = temporary_directory + 'Pods/BananaLib' path = temporary_directory + 'Pods/BananaLib'
path.mkpath path.mkpath
...@@ -174,11 +174,11 @@ module Pod ...@@ -174,11 +174,11 @@ module Pod
end end
it "returns whether the folder containing the Pod with the given name is empty" do it 'returns whether the folder containing the Pod with the given name is empty' do
@analyzer.send(:folder_empty?, 'BananaLib').should.be.true @analyzer.send(:folder_empty?, 'BananaLib').should.be.true
path = temporary_directory + 'Pods/BananaLib' path = temporary_directory + 'Pods/BananaLib'
path.mkpath path.mkpath
File.open(path + "file", "w") {} File.open(path + 'file', 'w') {}
@analyzer.send(:folder_empty?, 'BananaLib').should.be.false @analyzer.send(:folder_empty?, 'BananaLib').should.be.false
end end
......
...@@ -13,8 +13,8 @@ def create_analyzer ...@@ -13,8 +13,8 @@ def create_analyzer
end end
hash = {} hash = {}
hash['PODS'] = ["JSONKit (1.4)", "NUI (0.2.0)", "SVPullToRefresh (0.4)"] hash['PODS'] = ['JSONKit (1.4)', 'NUI (0.2.0)', 'SVPullToRefresh (0.4)']
hash['DEPENDENCIES'] = ["JSONKit", "NUI", "SVPullToRefresh"] hash['DEPENDENCIES'] = %w(JSONKit NUI SVPullToRefresh)
hash['SPEC CHECKSUMS'] = {} hash['SPEC CHECKSUMS'] = {}
hash['COCOAPODS'] = Pod::VERSION hash['COCOAPODS'] = Pod::VERSION
lockfile = Pod::Lockfile.new(hash) lockfile = Pod::Lockfile.new(hash)
...@@ -32,41 +32,41 @@ module Pod ...@@ -32,41 +32,41 @@ module Pod
@analyzer = create_analyzer @analyzer = create_analyzer
end end
describe "Analysis" do describe 'Analysis' do
it "returns whether an installation should be performed" do it 'returns whether an installation should be performed' do
@analyzer.needs_install?.should.be.true @analyzer.needs_install?.should.be.true
end end
it "returns whether the Podfile has changes" do it 'returns whether the Podfile has changes' do
analysis_result = @analyzer.analyze(false) analysis_result = @analyzer.analyze(false)
@analyzer.podfile_needs_install?(analysis_result).should.be.true @analyzer.podfile_needs_install?(analysis_result).should.be.true
end end
it "returns whether the sandbox is not in sync with the lockfile" do it 'returns whether the sandbox is not in sync with the lockfile' do
analysis_result = @analyzer.analyze(false) analysis_result = @analyzer.analyze(false)
@analyzer.sandbox_needs_install?(analysis_result).should.be.true @analyzer.sandbox_needs_install?(analysis_result).should.be.true
end end
#--------------------------------------# #--------------------------------------#
it "computes the state of the Podfile respect to the Lockfile" do it 'computes the state of the Podfile respect to the Lockfile' do
state = @analyzer.analyze.podfile_state state = @analyzer.analyze.podfile_state
state.added.should == ["AFNetworking", "libextobjc"] state.added.should == %w(AFNetworking libextobjc)
state.changed.should == ["JSONKit"] state.changed.should == ['JSONKit']
state.unchanged.should == ["SVPullToRefresh"] state.unchanged.should == ['SVPullToRefresh']
state.deleted.should == ["NUI"] state.deleted.should == ['NUI']
end end
#--------------------------------------# #--------------------------------------#
it "updates the repositories by default" do it 'updates the repositories by default' do
config.skip_repo_update = false config.skip_repo_update = false
SourcesManager.expects(:update).once SourcesManager.expects(:update).once
@analyzer.analyze @analyzer.analyze
end end
it "does not updates the repositories if config indicates to skip them" do it 'does not updates the repositories if config indicates to skip them' do
config.skip_repo_update = true config.skip_repo_update = true
SourcesManager.expects(:update).never SourcesManager.expects(:update).never
@analyzer.analyze @analyzer.analyze
...@@ -74,31 +74,31 @@ module Pod ...@@ -74,31 +74,31 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "generates the libraries which represent the target definitions" do it 'generates the libraries which represent the target definitions' do
target = @analyzer.analyze.targets.first target = @analyzer.analyze.targets.first
target.pod_targets.map(&:name).sort.should == [ target.pod_targets.map(&:name).sort.should == [
'Pods-JSONKit', 'Pods-JSONKit',
'Pods-AFNetworking', 'Pods-AFNetworking',
'Pods-SVPullToRefresh', 'Pods-SVPullToRefresh',
'Pods-libextobjc' 'Pods-libextobjc',
].sort ].sort
target.support_files_root.should == config.sandbox.root target.support_files_root.should == config.sandbox.root
target.user_project_path.to_s.should.include 'SampleProject/SampleProject' target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject' target.client_root.to_s.should.include 'SampleProject'
target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"] target.user_target_uuids.should == ['A346496C14F9BE9A0080D870']
user_proj = Xcodeproj::Project.open(target.user_project_path) user_proj = Xcodeproj::Project.open(target.user_project_path)
user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject' user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject'
target.user_build_configurations.should == { target.user_build_configurations.should == {
"Debug" => :debug, 'Debug' => :debug,
"Release" => :release, 'Release' => :release,
"Test" => :release, 'Test' => :release,
"App Store" => :release 'App Store' => :release,
} }
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
it "generates the integration library appropriately if the installation will not integrate" do it 'generates the integration library appropriately if the installation will not integrate' do
config.integrate_targets = false config.integrate_targets = false
target = @analyzer.analyze.targets.first target = @analyzer.analyze.targets.first
...@@ -108,26 +108,26 @@ module Pod ...@@ -108,26 +108,26 @@ module Pod
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
it "returns all the configurations the user has in any of its projects and/or targets" do it 'returns all the configurations the user has in any of its projects and/or targets' do
target_definition = @analyzer.podfile.target_definition_list.first target_definition = @analyzer.podfile.target_definition_list.first
target_definition.stubs(:build_configurations).returns("AdHoc" => :test) target_definition.stubs(:build_configurations).returns('AdHoc' => :test)
@analyzer.analyze.all_user_build_configurations.should == { @analyzer.analyze.all_user_build_configurations.should == {
"Debug" => :debug, 'Debug' => :debug,
"Release" => :release, 'Release' => :release,
"AdHoc" => :test, 'AdHoc' => :test,
"Test" => :release, 'Test' => :release,
"App Store" => :release 'App Store' => :release,
} }
end end
#--------------------------------------# #--------------------------------------#
it "locks the version of the dependencies which did not change in the Podfile" do it 'locks the version of the dependencies which did not change in the Podfile' do
@analyzer.analyze @analyzer.analyze
@analyzer.send(:locked_dependencies).map(&:to_s).should == ["SVPullToRefresh (= 0.4)"] @analyzer.send(:locked_dependencies).map(&:to_s).should == ['SVPullToRefresh (= 0.4)']
end end
it "does not lock the dependencies in update mode" do it 'does not lock the dependencies in update mode' do
@analyzer.update = true @analyzer.update = true
@analyzer.analyze @analyzer.analyze
@analyzer.send(:locked_dependencies).map(&:to_s).should == [] @analyzer.send(:locked_dependencies).map(&:to_s).should == []
...@@ -135,29 +135,29 @@ module Pod ...@@ -135,29 +135,29 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "fetches the dependencies with external sources" do it 'fetches the dependencies with external sources' do
podfile_state = Installer::Analyzer::SpecsState.new podfile_state = Installer::Analyzer::SpecsState.new
podfile_state.added << "BananaLib" podfile_state.added << 'BananaLib'
@analyzer.stubs(:result).returns(stub(:podfile_state => podfile_state)) @analyzer.stubs(:result).returns(stub(:podfile_state => podfile_state))
@podfile.stubs(:dependencies).returns([Dependency.new('BananaLib', :git => "example.com")]) @podfile.stubs(:dependencies).returns([Dependency.new('BananaLib', :git => 'example.com')])
ExternalSources::DownloaderSource.any_instance.expects(:fetch) ExternalSources::DownloaderSource.any_instance.expects(:fetch)
@analyzer.send(:fetch_external_sources) @analyzer.send(:fetch_external_sources)
end end
xit "it fetches the specification from either the sandbox or from the remote be default" do xit 'it fetches the specification from either the sandbox or from the remote be default' do
dependency = Dependency.new('Name', :git => 'www.example.com') dependency = Dependency.new('Name', :git => 'www.example.com')
ExternalSources::DownloaderSource.any_instance.expects(:specification_from_external).returns(Specification.new).once ExternalSources::DownloaderSource.any_instance.expects(:specification_from_external).returns(Specification.new).once
@resolver.send(:set_from_external_source, dependency) @resolver.send(:set_from_external_source, dependency)
end end
xit "it fetches the specification from the remote if in update mode" do xit 'it fetches the specification from the remote if in update mode' do
dependency = Dependency.new('Name', :git => 'www.example.com') dependency = Dependency.new('Name', :git => 'www.example.com')
ExternalSources::DownloaderSource.any_instance.expects(:specification).returns(Specification.new).once ExternalSources::DownloaderSource.any_instance.expects(:specification).returns(Specification.new).once
@resolver.update_external_specs = false @resolver.update_external_specs = false
@resolver.send(:set_from_external_source, dependency) @resolver.send(:set_from_external_source, dependency)
end end
xit "it fetches the specification only from the sandbox if pre-downloads are disabled" do xit 'it fetches the specification only from the sandbox if pre-downloads are disabled' do
dependency = Dependency.new('Name', :git => 'www.example.com') dependency = Dependency.new('Name', :git => 'www.example.com')
Sandbox.any_instance.expects(:specification).returns(Specification.new).once Sandbox.any_instance.expects(:specification).returns(Specification.new).once
@resolver.allow_pre_downloads = true @resolver.allow_pre_downloads = true
...@@ -166,49 +166,49 @@ module Pod ...@@ -166,49 +166,49 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "resolves the dependencies" do it 'resolves the dependencies' do
@analyzer.analyze.specifications.map(&:to_s).should == [ @analyzer.analyze.specifications.map(&:to_s).should == [
"AFNetworking (1.0.1)", 'AFNetworking (1.0.1)',
"JSONKit (1.5pre)", 'JSONKit (1.5pre)',
"SVPullToRefresh (0.4)", 'SVPullToRefresh (0.4)',
"libextobjc/EXTKeyPathCoding (0.2.3)" 'libextobjc/EXTKeyPathCoding (0.2.3)',
] ]
end end
xit "removes the specifications of the changed pods to prevent confusion in the resolution process" do xit 'removes the specifications of the changed pods to prevent confusion in the resolution process' do
@analyzer.allow_pre_downloads = true @analyzer.allow_pre_downloads = true
podspec = @analyzer.sandbox.root + 'Local Podspecs/JSONKit.podspec' podspec = @analyzer.sandbox.root + 'Local Podspecs/JSONKit.podspec'
podspec.dirname.mkpath podspec.dirname.mkpath
File.open(podspec, "w") { |f| f.puts('test') } File.open(podspec, 'w') { |f| f.puts('test') }
@analyzer.analyze @analyzer.analyze
podspec.should.not.exist? podspec.should.not.exist?
end end
it "adds the specifications to the correspondent libraries" do it 'adds the specifications to the correspondent libraries' do
@analyzer.analyze.targets.first.pod_targets.map(&:specs).flatten.map(&:to_s).should == [ @analyzer.analyze.targets.first.pod_targets.map(&:specs).flatten.map(&:to_s).should == [
"AFNetworking (1.0.1)", 'AFNetworking (1.0.1)',
"JSONKit (1.5pre)", 'JSONKit (1.5pre)',
"SVPullToRefresh (0.4)", 'SVPullToRefresh (0.4)',
"libextobjc/EXTKeyPathCoding (0.2.3)" 'libextobjc/EXTKeyPathCoding (0.2.3)',
] ]
end end
#--------------------------------------# #--------------------------------------#
it "computes the state of the Sandbox respect to the resolved dependencies" do it 'computes the state of the Sandbox respect to the resolved dependencies' do
@analyzer.stubs(:lockfile).returns(nil) @analyzer.stubs(:lockfile).returns(nil)
state = @analyzer.analyze.sandbox_state state = @analyzer.analyze.sandbox_state
state.added.sort.should == ["AFNetworking", "JSONKit", "SVPullToRefresh", "libextobjc"] state.added.sort.should == %w(AFNetworking JSONKit SVPullToRefresh libextobjc)
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private helpers" do describe 'Private helpers' do
describe "#compute_user_project_targets" do describe '#compute_user_project_targets' do
it "uses the path specified in the target definition while computing the path of the user project" do it 'uses the path specified in the target definition while computing the path of the user project' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.user_project_path = 'SampleProject/SampleProject' target_definition.user_project_path = 'SampleProject/SampleProject'
...@@ -216,7 +216,7 @@ module Pod ...@@ -216,7 +216,7 @@ module Pod
path.to_s.should.include 'SampleProject/SampleProject.xcodeproj' path.to_s.should.include 'SampleProject/SampleProject.xcodeproj'
end end
it "raises if the user project of the target definition does not exists while computing the path of the user project" do it 'raises if the user project of the target definition does not exists while computing the path of the user project' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.user_project_path = 'Test' target_definition.user_project_path = 'Test'
...@@ -224,7 +224,7 @@ module Pod ...@@ -224,7 +224,7 @@ module Pod
e.message.should.match /Unable to find/ e.message.should.match /Unable to find/
end end
it "if not specified in the target definition if looks if there is only one project" do it 'if not specified in the target definition if looks if there is only one project' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
config.installation_root = config.installation_root + 'SampleProject' config.installation_root = config.installation_root + 'SampleProject'
...@@ -232,14 +232,14 @@ module Pod ...@@ -232,14 +232,14 @@ module Pod
path.to_s.should.include 'SampleProject/SampleProject.xcodeproj' path.to_s.should.include 'SampleProject/SampleProject.xcodeproj'
end end
it "if not specified in the target definition if looks if there is only one project" do it 'if not specified in the target definition if looks if there is only one project' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
e = lambda { @analyzer.send(:compute_user_project_path, target_definition) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_path, target_definition) }.should.raise Informative
e.message.should.match /Could not.*select.*project/ e.message.should.match /Could not.*select.*project/
end end
it "does not take aggregate targets into consideration" do it 'does not take aggregate targets into consideration' do
aggregate_class = Xcodeproj::Project::Object::PBXAggregateTarget aggregate_class = Xcodeproj::Project::Object::PBXAggregateTarget
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
sample_project = Xcodeproj::Project.open(sample_project_path) sample_project = Xcodeproj::Project.open(sample_project_path)
...@@ -252,9 +252,9 @@ module Pod ...@@ -252,9 +252,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#compute_user_project_targets" do describe '#compute_user_project_targets' do
it "returns the targets specified in the target definition" do it 'returns the targets specified in the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = ['UserTarget'] target_definition.link_with = ['UserTarget']
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
...@@ -265,7 +265,7 @@ module Pod ...@@ -265,7 +265,7 @@ module Pod
targets.map(&:name).should == ['UserTarget'] targets.map(&:name).should == ['UserTarget']
end end
it "raises if it is unable to find the targets specified by the target definition" do it 'raises if it is unable to find the targets specified by the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = ['UserTarget'] target_definition.link_with = ['UserTarget']
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
...@@ -274,7 +274,7 @@ module Pod ...@@ -274,7 +274,7 @@ module Pod
e.message.should.match /Unable to find the targets/ e.message.should.match /Unable to find the targets/
end end
it "returns the target with the same name of the target definition" do it 'returns the target with the same name of the target definition' do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil) target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios) user_project.new_target(:application, 'FirstTarget', :ios)
...@@ -284,14 +284,14 @@ module Pod ...@@ -284,14 +284,14 @@ module Pod
targets.map(&:name).should == ['UserTarget'] targets.map(&:name).should == ['UserTarget']
end end
it "raises if the name of the target definition does not match any file" do it 'raises if the name of the target definition does not match any file' do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil) target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative
e.message.should.match /Unable to find a target named/ e.message.should.match /Unable to find a target named/
end end
it "returns the first target of the project if the target definition is named default" do it 'returns the first target of the project if the target definition is named default' do
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
...@@ -302,7 +302,7 @@ module Pod ...@@ -302,7 +302,7 @@ module Pod
targets.map(&:name).should == ['FirstTarget'] targets.map(&:name).should == ['FirstTarget']
end end
it "raises if the default target definition cannot be linked because there are no user targets" do it 'raises if the default target definition cannot be linked because there are no user targets' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative
...@@ -313,9 +313,9 @@ module Pod ...@@ -313,9 +313,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#compute_user_build_configurations" do describe '#compute_user_build_configurations' do
it "returns the user build configurations of the user targets" do it 'returns the user build configurations of the user targets' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
configuration = user_project.new(Xcodeproj::Project::Object::XCBuildConfiguration) configuration = user_project.new(Xcodeproj::Project::Object::XCBuildConfiguration)
...@@ -329,11 +329,11 @@ module Pod ...@@ -329,11 +329,11 @@ module Pod
configurations.should == { configurations.should == {
'Debug' => :debug, 'Debug' => :debug,
'Release' => :release, 'Release' => :release,
'AppStore' => :release 'AppStore' => :release,
} }
end end
it "returns the user build configurations specified in the target definition" do it 'returns the user build configurations specified in the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.build_configurations = { 'AppStore' => :release } target_definition.build_configurations = { 'AppStore' => :release }
user_targets = [] user_targets = []
...@@ -346,9 +346,9 @@ module Pod ...@@ -346,9 +346,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#compute_archs_for_target_definition" do describe '#compute_archs_for_target_definition' do
it "handles a single ARCH defined in a single user target" do it 'handles a single ARCH defined in a single user target' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
target.build_configuration_list.set_setting('ARCHS', 'armv7') target.build_configuration_list.set_setting('ARCHS', 'armv7')
...@@ -361,7 +361,7 @@ module Pod ...@@ -361,7 +361,7 @@ module Pod
archs.should == 'armv7' archs.should == 'armv7'
end end
it "handles a single ARCH defined in multiple user targets" do it 'handles a single ARCH defined in multiple user targets' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
targeta = user_project.new_target(:application, 'Target', :ios) targeta = user_project.new_target(:application, 'Target', :ios)
targeta.build_configuration_list.set_setting('ARCHS', 'armv7') targeta.build_configuration_list.set_setting('ARCHS', 'armv7')
...@@ -376,40 +376,40 @@ module Pod ...@@ -376,40 +376,40 @@ module Pod
archs.should == 'armv7' archs.should == 'armv7'
end end
it "handles an Array of ARCHs defined in a single user target" do it 'handles an Array of ARCHs defined in a single user target' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
target.build_configuration_list.set_setting('ARCHS', ['armv7', 'i386']) target.build_configuration_list.set_setting('ARCHS', %w(armv7 i386))
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.set_platform(:ios, '4.0') target_definition.set_platform(:ios, '4.0')
user_targets = [target] user_targets = [target]
archs = @analyzer.send(:compute_archs_for_target_definition, target_definition, user_targets) archs = @analyzer.send(:compute_archs_for_target_definition, target_definition, user_targets)
['armv7', 'i386'].each { |a| archs.should.include a } %w(armv7 i386).each { |a| archs.should.include a }
end end
it "handles an Array of ARCHs defined multiple user targets" do it 'handles an Array of ARCHs defined multiple user targets' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
targeta = user_project.new_target(:application, 'Target', :ios) targeta = user_project.new_target(:application, 'Target', :ios)
targeta.build_configuration_list.set_setting('ARCHS', ['armv7', 'armv7s']) targeta.build_configuration_list.set_setting('ARCHS', %w(armv7 armv7s))
targetb = user_project.new_target(:application, 'Target', :ios) targetb = user_project.new_target(:application, 'Target', :ios)
targetb.build_configuration_list.set_setting('ARCHS', ['armv7', 'i386']) targetb.build_configuration_list.set_setting('ARCHS', %w(armv7 i386))
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.set_platform(:ios, '4.0') target_definition.set_platform(:ios, '4.0')
user_targets = [targeta, targetb] user_targets = [targeta, targetb]
archs = @analyzer.send(:compute_archs_for_target_definition, target_definition, user_targets) archs = @analyzer.send(:compute_archs_for_target_definition, target_definition, user_targets)
['armv7', 'armv7s', 'i386'].each { |a| archs.should.include a } %w(armv7 armv7s i386).each { |a| archs.should.include a }
end end
end end
#--------------------------------------# #--------------------------------------#
describe "#compute_platform_for_target_definition" do describe '#compute_platform_for_target_definition' do
it "returns the platform specified in the target definition" do it 'returns the platform specified in the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.set_platform(:ios, '4.0') target_definition.set_platform(:ios, '4.0')
user_targets = [] user_targets = []
...@@ -418,7 +418,7 @@ module Pod ...@@ -418,7 +418,7 @@ module Pod
configurations.should == Platform.new(:ios, '4.0') configurations.should == Platform.new(:ios, '4.0')
end end
it "infers the platform from the user targets" do it 'infers the platform from the user targets' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
target.build_configuration_list.set_setting('SDKROOT', 'iphoneos') target.build_configuration_list.set_setting('SDKROOT', 'iphoneos')
...@@ -431,7 +431,7 @@ module Pod ...@@ -431,7 +431,7 @@ module Pod
configurations.should == Platform.new(:ios, '4.0') configurations.should == Platform.new(:ios, '4.0')
end end
it "uses the lowest deployment target of the user targets if inferring the platform" do it 'uses the lowest deployment target of the user targets if inferring the platform' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target1 = user_project.new_target(:application, 'Target', :ios) target1 = user_project.new_target(:application, 'Target', :ios)
configuration1 = target1.build_configuration_list.build_configurations.first configuration1 = target1.build_configuration_list.build_configurations.first
...@@ -449,7 +449,7 @@ module Pod ...@@ -449,7 +449,7 @@ module Pod
configurations.should == Platform.new(:ios, '4.0') configurations.should == Platform.new(:ios, '4.0')
end end
it "raises if the user targets have a different platform" do it 'raises if the user targets have a different platform' do
user_project = Xcodeproj::Project.new('path') user_project = Xcodeproj::Project.new('path')
target1 = user_project.new_target(:application, 'Target', :ios) target1 = user_project.new_target(:application, 'Target', :ios)
target1.build_configuration_list.set_setting('SDKROOT', 'iphoneos') target1.build_configuration_list.set_setting('SDKROOT', 'iphoneos')
......
...@@ -14,43 +14,43 @@ module Pod ...@@ -14,43 +14,43 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Installation" do describe 'Installation' do
it "adds the files references of the source files the Pods project" do it 'adds the files references of the source files the Pods project' do
@file_accessor.path_list.read_file_system @file_accessor.path_list.read_file_system
@file_accessor.path_list.expects(:read_file_system) @file_accessor.path_list.expects(:read_file_system)
@installer.install! @installer.install!
end end
it "adds the files references of the source files the Pods project" do it 'adds the files references of the source files the Pods project' do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Banana.m'] file_ref = @installer.pods_project['Pods/BananaLib/Banana.m']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "Classes/Banana.m" file_ref.path.should == 'Classes/Banana.m'
end end
it "adds the file references of the frameworks of the project" do it 'adds the file references of the frameworks of the project' do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Frameworks/Bananalib.framework'] file_ref = @installer.pods_project['Pods/BananaLib/Frameworks/Bananalib.framework']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "Bananalib.framework" file_ref.path.should == 'Bananalib.framework'
end end
it "adds the file references of the libraries of the project" do it 'adds the file references of the libraries of the project' do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Frameworks/libBananalib.a'] file_ref = @installer.pods_project['Pods/BananaLib/Frameworks/libBananalib.a']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "libBananalib.a" file_ref.path.should == 'libBananalib.a'
end end
it "adds the files references of the resources the Pods project" do it 'adds the files references of the resources the Pods project' do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png'] file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "Resources/logo-sidebar.png" file_ref.path.should == 'Resources/logo-sidebar.png'
end end
it "links the build headers" do it 'links the build headers' do
@installer.install! @installer.install!
headers_root = @pod_target.build_headers.root headers_root = @pod_target.build_headers.root
public_header = headers_root + 'BananaLib/Banana.h' public_header = headers_root + 'BananaLib/Banana.h'
...@@ -59,7 +59,7 @@ module Pod ...@@ -59,7 +59,7 @@ module Pod
private_header.should.exist private_header.should.exist
end end
it "links the public headers" do it 'links the public headers' do
@installer.install! @installer.install!
headers_root = config.sandbox.public_headers.root headers_root = config.sandbox.public_headers.root
public_header = headers_root + 'BananaLib/Banana.h' public_header = headers_root + 'BananaLib/Banana.h'
...@@ -72,10 +72,10 @@ module Pod ...@@ -72,10 +72,10 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private Helpers" do describe 'Private Helpers' do
describe "#file_accessors" do describe '#file_accessors' do
it "returns the file accessors" do it 'returns the file accessors' do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target_1 = PodTarget.new([], nil, config.sandbox)
pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
pod_target_2 = PodTarget.new([], nil, config.sandbox) pod_target_2 = PodTarget.new([], nil, config.sandbox)
...@@ -85,7 +85,7 @@ module Pod ...@@ -85,7 +85,7 @@ module Pod
roots.should == [fixture('banana-lib'), fixture('banana-lib')] roots.should == [fixture('banana-lib'), fixture('banana-lib')]
end end
it "handles libraries empty libraries without file accessors" do it 'handles libraries empty libraries without file accessors' do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target_1 = PodTarget.new([], nil, config.sandbox)
pod_target_1.file_accessors = [] pod_target_1.file_accessors = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1], @project) installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1], @project)
...@@ -93,31 +93,31 @@ module Pod ...@@ -93,31 +93,31 @@ module Pod
end end
end end
describe "#header_mappings" do describe '#header_mappings' do
it "returns the header mappings" do it 'returns the header mappings' do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
headers = [Pathname.new('BananaLib/Banana.h')] headers = [Pathname.new('BananaLib/Banana.h')]
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers) mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings.should == { mappings.should == {
headers_sandbox => [Pathname.new('BananaLib/Banana.h')] headers_sandbox => [Pathname.new('BananaLib/Banana.h')],
} }
end end
it "takes into account the header dir specified in the spec" do it 'takes into account the header dir specified in the spec' do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
headers = [Pathname.new('BananaLib/Banana.h')] headers = [Pathname.new('BananaLib/Banana.h')]
@file_accessor.spec_consumer.stubs(:header_dir).returns('Sub_dir') @file_accessor.spec_consumer.stubs(:header_dir).returns('Sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers) mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings.should == { mappings.should == {
(headers_sandbox + 'Sub_dir') => [Pathname.new('BananaLib/Banana.h')] (headers_sandbox + 'Sub_dir') => [Pathname.new('BananaLib/Banana.h')],
} }
end end
it "takes into account the header mappings dir specified in the spec" do it 'takes into account the header mappings dir specified in the spec' do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
header_1 = @file_accessor.root + 'BananaLib/sub_dir/dir_1/banana_1.h' header_1 = @file_accessor.root + 'BananaLib/sub_dir/dir_1/banana_1.h'
header_2 = @file_accessor.root + 'BananaLib/sub_dir/dir_2/banana_2.h' header_2 = @file_accessor.root + 'BananaLib/sub_dir/dir_2/banana_2.h'
headers = [ header_1, header_2 ] headers = [header_1, header_2]
@file_accessor.spec_consumer.stubs(:header_mappings_dir).returns('BananaLib/sub_dir') @file_accessor.spec_consumer.stubs(:header_mappings_dir).returns('BananaLib/sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers) mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings.should == { mappings.should == {
...@@ -133,5 +133,3 @@ module Pod ...@@ -133,5 +133,3 @@ module Pod
end end
end end
...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Installer::HooksContext do describe Installer::HooksContext do
it "offers a convenience method to be generated" do it 'offers a convenience method to be generated' do
sandbox = stub(:root => '/path') sandbox = stub(:root => '/path')
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
......
...@@ -12,10 +12,10 @@ module Pod ...@@ -12,10 +12,10 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Installation" do describe 'Installation' do
describe "Download" do describe 'Download' do
it "downloads the source" do it 'downloads the source' do
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
@installer.specific_source.should.be.nil @installer.specific_source.should.be.nil
...@@ -23,35 +23,35 @@ module Pod ...@@ -23,35 +23,35 @@ module Pod
pod_folder.should.exist pod_folder.should.exist
end end
it "downloads the head source even if a specific source is present specified source" do it 'downloads the head source even if a specific source is present specified source' do
config.sandbox.store_head_pod('BananaLib') config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
@installer.specific_source[:commit].should == "0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc" @installer.specific_source[:commit].should == '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc'
pod_folder = config.sandbox.root + 'BananaLib' pod_folder = config.sandbox.root + 'BananaLib'
pod_folder.should.exist pod_folder.should.exist
end end
it "returns the checkout options of the downloader if any" do it 'returns the checkout options of the downloader if any' do
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :branch => 'topicbranch' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :branch => 'topicbranch' }
@installer.install! @installer.install!
@installer.specific_source[:commit].should == "446b22414597f1bb4062a62c4eed7af9627a3f1b" @installer.specific_source[:commit].should == '446b22414597f1bb4062a62c4eed7af9627a3f1b'
pod_folder = config.sandbox.root + 'BananaLib' pod_folder = config.sandbox.root + 'BananaLib'
pod_folder.should.exist pod_folder.should.exist
end end
it "stores the checkout options in the sandbox" do it 'stores the checkout options in the sandbox' do
config.sandbox.store_head_pod('BananaLib') config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
sources = @installer.sandbox.checkout_sources sources = @installer.sandbox.checkout_sources
sources.should == { "BananaLib" => { sources.should == { 'BananaLib' => {
:git => SpecHelper.fixture('banana-lib'), :git => SpecHelper.fixture('banana-lib'),
:commit=>"0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc" } :commit => '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc' },
} }
end end
it "cleans up directory when an error occurs during download" do it 'cleans up directory when an error occurs during download' do
config.sandbox.store_head_pod('BananaLib') config.sandbox.store_head_pod('BananaLib')
pod_folder = config.sandbox.root + 'BananaLib' pod_folder = config.sandbox.root + 'BananaLib'
partially_downloaded_file = pod_folder + 'partially_downloaded_file' partially_downloaded_file = pod_folder + 'partially_downloaded_file'
...@@ -61,17 +61,17 @@ module Pod ...@@ -61,17 +61,17 @@ module Pod
singleton_class.send(:define_method, :download_head) do singleton_class.send(:define_method, :download_head) do
FileUtils.mkdir_p(pod_folder) FileUtils.mkdir_p(pod_folder)
FileUtils.touch(partially_downloaded_file) FileUtils.touch(partially_downloaded_file)
raise("some network error") raise('some network error')
end end
@installer.stubs(:downloader).returns(mock_downloader) @installer.stubs(:downloader).returns(mock_downloader)
lambda { lambda do
@installer.install! @installer.install!
}.should.raise(RuntimeError).message.should.equal('some network error') end.should.raise(RuntimeError).message.should.equal('some network error')
partially_downloaded_file.should.not.exist partially_downloaded_file.should.not.exist
end end
it "fails when using :head for Http source" do it 'fails when using :head for Http source' do
config.sandbox.store_head_pod('BananaLib') config.sandbox.store_head_pod('BananaLib')
@spec.source = { :http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip' } @spec.source = { :http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip' }
@spec.source_files = 'GoogleAdMobSearchAdsSDK/*.h' @spec.source_files = 'GoogleAdMobSearchAdsSDK/*.h'
...@@ -85,9 +85,9 @@ module Pod ...@@ -85,9 +85,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "Prepare command" do describe 'Prepare command' do
it "runs the prepare command if one has been declared in the spec" do it 'runs the prepare command if one has been declared in the spec' do
@spec.prepare_command = "echo test" @spec.prepare_command = 'echo test'
@installer.expects(:bash!).once @installer.expects(:bash!).once
@installer.install! @installer.install!
end end
...@@ -97,33 +97,33 @@ module Pod ...@@ -97,33 +97,33 @@ module Pod
@installer.install! @installer.install!
end end
it "raises if the prepare command fails" do it 'raises if the prepare command fails' do
@spec.prepare_command = "missing_command" @spec.prepare_command = 'missing_command'
should.raise Informative do should.raise Informative do
@installer.install! @installer.install!
end.message.should.match /command not found/ end.message.should.match /command not found/
end end
it "unsets $CDPATH environment variable" do it 'unsets $CDPATH environment variable' do
ENV['CDPATH'] = "BogusPath" ENV['CDPATH'] = 'BogusPath'
@spec.prepare_command = "cd Classes;ls Banana.h" @spec.prepare_command = 'cd Classes;ls Banana.h'
lambda { @installer.install! }.should.not.raise lambda { @installer.install! }.should.not.raise
end end
end end
#--------------------------------------# #--------------------------------------#
describe "Cleaning" do describe 'Cleaning' do
it "cleans the paths non used by the installation" do it 'cleans the paths non used by the installation' do
@installer.install! @installer.install!
@installer.clean! @installer.clean!
unused_file = config.sandbox.root + 'BananaLib/sub-dir/sub-dir-2/somefile.txt' unused_file = config.sandbox.root + 'BananaLib/sub-dir/sub-dir-2/somefile.txt'
unused_file.should.not.exist unused_file.should.not.exist
end end
it "preserves important files like the LICENSE and the README" do it 'preserves important files like the LICENSE and the README' do
@installer.install! @installer.install!
@installer.clean! @installer.clean!
readme_file = config.sandbox.root + 'BananaLib/README' readme_file = config.sandbox.root + 'BananaLib/README'
...@@ -134,7 +134,7 @@ module Pod ...@@ -134,7 +134,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "Options" do describe 'Options' do
it "doesn't downloads the source if the pod was already downloaded" do it "doesn't downloads the source if the pod was already downloaded" do
@installer.stubs(:predownloaded?).returns(true) @installer.stubs(:predownloaded?).returns(true)
...@@ -163,38 +163,38 @@ module Pod ...@@ -163,38 +163,38 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private Helpers" do describe 'Private Helpers' do
it "returns the clean paths" do it 'returns the clean paths' do
@installer.send(:download_source) @installer.send(:download_source)
paths = @installer.send(:clean_paths) paths = @installer.send(:clean_paths)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '')} relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
paths_without_git = relative_paths.reject { |p| p.include? 'Pods/BananaLib/.git' } paths_without_git = relative_paths.reject { |p| p.include? 'Pods/BananaLib/.git' }
paths_without_git.sort.should == [ paths_without_git.sort.should == [
"Pods/BananaLib/BananaLib.podspec", 'Pods/BananaLib/BananaLib.podspec',
"Pods/BananaLib/libPusher", 'Pods/BananaLib/libPusher',
"Pods/BananaLib/sub-dir", 'Pods/BananaLib/sub-dir',
"Pods/BananaLib/sub-dir/sub-dir-2", 'Pods/BananaLib/sub-dir/sub-dir-2',
"Pods/BananaLib/sub-dir/sub-dir-2/somefile.txt" 'Pods/BananaLib/sub-dir/sub-dir-2/somefile.txt',
] ]
end end
it "returns the used files" do it 'returns the used files' do
@installer.send(:download_source) @installer.send(:download_source)
paths = @installer.send(:used_files) paths = @installer.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '')} relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
"Pods/BananaLib/Classes/Banana.h", 'Pods/BananaLib/Classes/Banana.h',
"Pods/BananaLib/Classes/Banana.m", 'Pods/BananaLib/Classes/Banana.m',
"Pods/BananaLib/Classes/BananaLib.pch", 'Pods/BananaLib/Classes/BananaLib.pch',
"Pods/BananaLib/Classes/BananaPrivate.h", 'Pods/BananaLib/Classes/BananaPrivate.h',
"Pods/BananaLib/LICENSE", 'Pods/BananaLib/LICENSE',
"Pods/BananaLib/README", 'Pods/BananaLib/README',
"Pods/BananaLib/Resources/logo-sidebar.png" 'Pods/BananaLib/Resources/logo-sidebar.png',
] ]
end end
it "handles Pods with multiple file accessors" do it 'handles Pods with multiple file accessors' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
spec.source = { :git => SpecHelper.fixture('banana-lib') } spec.source = { :git => SpecHelper.fixture('banana-lib') }
spec.source_files = [] spec.source_files = []
...@@ -206,19 +206,19 @@ module Pod ...@@ -206,19 +206,19 @@ module Pod
@installer = Installer::PodSourceInstaller.new(config.sandbox, specs_by_platform) @installer = Installer::PodSourceInstaller.new(config.sandbox, specs_by_platform)
@installer.send(:download_source) @installer.send(:download_source)
paths = @installer.send(:used_files) paths = @installer.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '')} relative_paths = paths.map { |p| p.gsub("#{temporary_directory}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
"Pods/BananaLib/Classes/Banana.h", 'Pods/BananaLib/Classes/Banana.h',
"Pods/BananaLib/Classes/Banana.m", 'Pods/BananaLib/Classes/Banana.m',
"Pods/BananaLib/Classes/BananaLib.pch", 'Pods/BananaLib/Classes/BananaLib.pch',
"Pods/BananaLib/Classes/BananaPrivate.h", 'Pods/BananaLib/Classes/BananaPrivate.h',
"Pods/BananaLib/LICENSE", 'Pods/BananaLib/LICENSE',
"Pods/BananaLib/README", 'Pods/BananaLib/README',
"Pods/BananaLib/Resources/logo-sidebar.png" 'Pods/BananaLib/Resources/logo-sidebar.png',
] ]
end end
it "compacts the used files as nil would be converted to the empty string" do it 'compacts the used files as nil would be converted to the empty string' do
Sandbox::FileAccessor.any_instance.stubs(:source_files) Sandbox::FileAccessor.any_instance.stubs(:source_files)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries) Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries)
Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil) Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil)
......
...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod module Pod
describe Installer::AggregateTargetInstaller do describe Installer::AggregateTargetInstaller do
describe "In General" do describe 'In General' do
before do before do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios
...@@ -39,19 +39,19 @@ module Pod ...@@ -39,19 +39,19 @@ module Pod
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
end end
it "adds file references for the support files of the target" do it 'adds file references for the support files of the target' do
@installer.install! @installer.install!
group = @project.support_files_group['Pods'] group = @project.support_files_group['Pods']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
"Pods-acknowledgements.markdown", 'Pods-acknowledgements.markdown',
"Pods-acknowledgements.plist", 'Pods-acknowledgements.plist',
"Pods-dummy.m", 'Pods-dummy.m',
"Pods-environment.h", 'Pods-environment.h',
"Pods-resources.sh", 'Pods-resources.sh',
"Pods.appstore.xcconfig", 'Pods.appstore.xcconfig',
"Pods.debug.xcconfig", 'Pods.debug.xcconfig',
"Pods.release.xcconfig", 'Pods.release.xcconfig',
"Pods.test.xcconfig" 'Pods.test.xcconfig',
] ]
end end
...@@ -63,50 +63,50 @@ module Pod ...@@ -63,50 +63,50 @@ module Pod
@project.targets.first.name.should == @target_definition.label @project.targets.first.name.should == @target_definition.label
end end
it "adds the user build configurations to the target" do it 'adds the user build configurations to the target' do
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.build_settings('Test')["VALIDATE_PRODUCT"].should == nil target.build_settings('Test')['VALIDATE_PRODUCT'].should.nil?
target.build_settings('AppStore')["VALIDATE_PRODUCT"].should == "YES" target.build_settings('AppStore')['VALIDATE_PRODUCT'].should == 'YES'
end end
it "sets VALIDATE_PRODUCT to YES for the Release configuration for iOS targets" do it 'sets VALIDATE_PRODUCT to YES for the Release configuration for iOS targets' do
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.build_settings('Release')["VALIDATE_PRODUCT"].should == "YES" target.build_settings('Release')['VALIDATE_PRODUCT'].should == 'YES'
end end
it "sets the platform and the deployment target for iOS targets" do it 'sets the platform and the deployment target for iOS targets' do
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.platform_name.should == :ios target.platform_name.should == :ios
target.deployment_target.should == "6.0" target.deployment_target.should == '6.0'
target.build_settings('Debug')["IPHONEOS_DEPLOYMENT_TARGET"].should == "6.0" target.build_settings('Debug')['IPHONEOS_DEPLOYMENT_TARGET'].should == '6.0'
target.build_settings('AppStore')["IPHONEOS_DEPLOYMENT_TARGET"].should == "6.0" target.build_settings('AppStore')['IPHONEOS_DEPLOYMENT_TARGET'].should == '6.0'
end end
it "sets the platform and the deployment target for OS X targets" do it 'sets the platform and the deployment target for OS X targets' do
@target.stubs(:platform).returns(Platform.new(:osx, '10.8')) @target.stubs(:platform).returns(Platform.new(:osx, '10.8'))
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.platform_name.should == :osx target.platform_name.should == :osx
target.deployment_target.should == "10.8" target.deployment_target.should == '10.8'
target.build_settings('Debug')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8" target.build_settings('Debug')['MACOSX_DEPLOYMENT_TARGET'].should == '10.8'
target.build_settings('AppStore')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8" target.build_settings('AppStore')['MACOSX_DEPLOYMENT_TARGET'].should == '10.8'
end end
it "adds the user's build configurations to the target" do it "adds the user's build configurations to the target" do
@installer.install! @installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test } @project.targets.first.build_configurations.map(&:name).sort.should == %w( AppStore Debug Release Test )
end end
it "it creates different hash instances for the build settings of various build configurations" do it 'it creates different hash instances for the build settings of various build configurations' do
@installer.install! @installer.install!
build_settings = @project.targets.first.build_configurations.map(&:build_settings) build_settings = @project.targets.first.build_configurations.map(&:build_settings)
build_settings.map(&:object_id).uniq.count.should == 4 build_settings.map(&:object_id).uniq.count.should == 4
end end
it "does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default" do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.target.build_configurations.each do |config| @installer.library.target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
...@@ -115,14 +115,14 @@ module Pod ...@@ -115,14 +115,14 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "creates the xcconfig file" do it 'creates the xcconfig file' do
@installer.install! @installer.install!
file = config.sandbox.root + @target.xcconfig_path("Release") file = config.sandbox.root + @target.xcconfig_path('Release')
xcconfig = Xcodeproj::Config.new(file) xcconfig = Xcodeproj::Config.new(file)
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods' xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end end
it "creates a header for the target which contains the information about the installed Pods" do it 'creates a header for the target which contains the information about the installed Pods' do
@installer.install! @installer.install!
file = config.sandbox.root + 'Pods-environment.h' file = config.sandbox.root + 'Pods-environment.h'
contents = file.read contents = file.read
...@@ -132,27 +132,27 @@ module Pod ...@@ -132,27 +132,27 @@ module Pod
contents.should.include?('#define COCOAPODS_VERSION_PATCH_BananaLib 0') contents.should.include?('#define COCOAPODS_VERSION_PATCH_BananaLib 0')
end end
it "creates a bridge support file" do it 'creates a bridge support file' do
Podfile.any_instance.stubs(:generate_bridge_support? => true) Podfile.any_instance.stubs(:generate_bridge_support? => true)
Generator::BridgeSupport.any_instance.expects(:save_as).once Generator::BridgeSupport.any_instance.expects(:save_as).once
@installer.install! @installer.install!
end end
it "creates a create copy resources script" do it 'creates a create copy resources script' do
@installer.install! @installer.install!
script = config.sandbox.root + 'Pods-resources.sh' script = config.sandbox.root + 'Pods-resources.sh'
script.read.should.include?('logo-sidebar.png') script.read.should.include?('logo-sidebar.png')
end end
xit "adds the resources bundles to the copy resources script" do xit 'adds the resources bundles to the copy resources script' do
end end
xit "adds the bridge support file to the copy resources script, if one was created" do xit 'adds the bridge support file to the copy resources script, if one was created' do
end end
it "creates the acknowledgements files " do it 'creates the acknowledgements files ' do
@installer.install! @installer.install!
markdown = config.sandbox.root + 'Pods-acknowledgements.markdown' markdown = config.sandbox.root + 'Pods-acknowledgements.markdown'
markdown.read.should.include?('Permission is hereby granted') markdown.read.should.include?('Permission is hereby granted')
...@@ -160,7 +160,7 @@ module Pod ...@@ -160,7 +160,7 @@ module Pod
plist.read.should.include?('Permission is hereby granted') plist.read.should.include?('Permission is hereby granted')
end end
it "creates a dummy source to ensure the creation of a single base library" do it 'creates a dummy source to ensure the creation of a single base library' do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.library.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') } build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
......
...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod module Pod
describe Installer::PodTargetInstaller do describe Installer::PodTargetInstaller do
describe "In General" do describe 'In General' do
before do before do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios
...@@ -30,15 +30,15 @@ module Pod ...@@ -30,15 +30,15 @@ module Pod
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
end end
it "adds file references for the support files of the target" do it 'adds file references for the support files of the target' do
@installer.install! @installer.install!
@project.support_files_group @project.support_files_group
group = @project['Pods/BananaLib/Support Files'] group = @project['Pods/BananaLib/Support Files']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
"Pods-BananaLib-Private.xcconfig", 'Pods-BananaLib-Private.xcconfig',
"Pods-BananaLib-dummy.m", 'Pods-BananaLib-dummy.m',
"Pods-BananaLib-prefix.pch", 'Pods-BananaLib-prefix.pch',
"Pods-BananaLib.xcconfig", 'Pods-BananaLib.xcconfig',
] ]
end end
...@@ -50,42 +50,42 @@ module Pod ...@@ -50,42 +50,42 @@ module Pod
@project.targets.first.name.should == 'Pods-BananaLib' @project.targets.first.name.should == 'Pods-BananaLib'
end end
it "sets VALIDATE_PRODUCT to YES for the Release configuration for iOS targets" do it 'sets VALIDATE_PRODUCT to YES for the Release configuration for iOS targets' do
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.build_settings('Release')["VALIDATE_PRODUCT"].should == "YES" target.build_settings('Release')['VALIDATE_PRODUCT'].should == 'YES'
end end
it "sets the platform and the deployment target for iOS targets" do it 'sets the platform and the deployment target for iOS targets' do
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.platform_name.should == :ios target.platform_name.should == :ios
target.deployment_target.should == "6.0" target.deployment_target.should == '6.0'
target.build_settings('Debug')["IPHONEOS_DEPLOYMENT_TARGET"].should == "6.0" target.build_settings('Debug')['IPHONEOS_DEPLOYMENT_TARGET'].should == '6.0'
end end
it "sets the platform and the deployment target for OS X targets" do it 'sets the platform and the deployment target for OS X targets' do
@pod_target.stubs(:platform).returns(Platform.new(:osx, '10.8')) @pod_target.stubs(:platform).returns(Platform.new(:osx, '10.8'))
@installer.install! @installer.install!
target = @project.targets.first target = @project.targets.first
target.platform_name.should == :osx target.platform_name.should == :osx
target.deployment_target.should == "10.8" target.deployment_target.should == '10.8'
target.build_settings('Debug')["MACOSX_DEPLOYMENT_TARGET"].should == "10.8" target.build_settings('Debug')['MACOSX_DEPLOYMENT_TARGET'].should == '10.8'
end end
it "adds the user's build configurations to the target" do it "adds the user's build configurations to the target" do
@pod_target.user_build_configurations.merge!({ 'AppStore' => :release, 'Test' => :debug }) @pod_target.user_build_configurations.merge!('AppStore' => :release, 'Test' => :debug)
@installer.install! @installer.install!
@project.targets.first.build_configurations.map(&:name).sort.should == %w{ AppStore Debug Release Test } @project.targets.first.build_configurations.map(&:name).sort.should == %w( AppStore Debug Release Test )
end end
it "it creates different hash instances for the build settings of various build configurations" do it 'it creates different hash instances for the build settings of various build configurations' do
@installer.install! @installer.install!
build_settings = @project.targets.first.build_configurations.map(&:build_settings) build_settings = @project.targets.first.build_configurations.map(&:build_settings)
build_settings.map(&:object_id).uniq.count.should == 2 build_settings.map(&:object_id).uniq.count.should == 2
end end
it "does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default" do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.target.build_configurations.each do |config| @installer.library.target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
...@@ -97,15 +97,15 @@ module Pod ...@@ -97,15 +97,15 @@ module Pod
it 'adds the source files of each pod to the target of the Pod library' do it 'adds the source files of each pod to the target of the Pod library' do
@installer.install! @installer.install!
names = @installer.library.target.source_build_phase.files.map { |bf| bf.file_ref.display_name } names = @installer.library.target.source_build_phase.files.map { |bf| bf.file_ref.display_name }
names.should.include("Banana.m") names.should.include('Banana.m')
end end
#--------------------------------------# #--------------------------------------#
it 'adds the resource bundle targets' do it 'adds the resource bundle targets' do
@pod_target.file_accessors.first.stubs(:resource_bundles).returns({'banana_bundle' => []}) @pod_target.file_accessors.first.stubs(:resource_bundles).returns('banana_bundle' => [])
@installer.install! @installer.install!
@project.targets.map(&:name).should == ["Pods-BananaLib", "banana_bundle"] @project.targets.map(&:name).should == ['Pods-BananaLib', 'banana_bundle']
end end
xit 'adds the build configurations to the resources bundle targets' do xit 'adds the build configurations to the resources bundle targets' do
...@@ -114,7 +114,7 @@ module Pod ...@@ -114,7 +114,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "creates the xcconfig file" do it 'creates the xcconfig file' do
@installer.install! @installer.install!
file = config.sandbox.root + @pod_target.xcconfig_private_path file = config.sandbox.root + @pod_target.xcconfig_private_path
xcconfig = Xcodeproj::Config.new(file) xcconfig = Xcodeproj::Config.new(file)
...@@ -138,7 +138,7 @@ module Pod ...@@ -138,7 +138,7 @@ module Pod
generated.should == expected generated.should == expected
end end
it "creates a dummy source to ensure the compilation of libraries with only categories" do it 'creates a dummy source to ensure the compilation of libraries with only categories' do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.library.target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' } build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' }
...@@ -148,26 +148,25 @@ module Pod ...@@ -148,26 +148,25 @@ module Pod
dummy.read.should.include?('@interface PodsDummy_Pods') dummy.read.should.include?('@interface PodsDummy_Pods')
end end
#--------------------------------------------------------------------------------# #--------------------------------------------------------------------------------#
describe "concerning compiler flags" do describe 'concerning compiler flags' do
before do before do
@spec = Pod::Spec.new @spec = Pod::Spec.new
end end
it "flags should not be added to dtrace files" do it 'flags should not be added to dtrace files' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
@installer.install! @installer.install!
dtrace_files = @installer.library.target.source_build_phase.files.reject {|sf| dtrace_files = @installer.library.target.source_build_phase.files.reject do|sf|
!(File.extname(sf.file_ref.path) == '.d') !(File.extname(sf.file_ref.path) == '.d')
} end
dtrace_files.each do |dt| dtrace_files.each do |dt|
dt.settings.should.be.nil dt.settings.should.be.nil
end end
end end
it "adds -w per pod if target definition inhibits warnings for that pod" do it 'adds -w per pod if target definition inhibits warnings for that pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
...@@ -179,7 +178,7 @@ module Pod ...@@ -179,7 +178,7 @@ module Pod
flags.should.not.include?('-w') flags.should.not.include?('-w')
end end
it "adds -Xanalyzer -analyzer-disable-checker per pod" do it 'adds -Xanalyzer -analyzer-disable-checker per pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
...@@ -191,9 +190,9 @@ module Pod ...@@ -191,9 +190,9 @@ module Pod
flags.should.not.include?('-Xanalyzer -analyzer-disable-checker') flags.should.not.include?('-Xanalyzer -analyzer-disable-checker')
end end
describe "concerning ARC before and after iOS 6.0 and OS X 10.8" do describe 'concerning ARC before and after iOS 6.0 and OS X 10.8' do
it "does not do anything if ARC is *not* required" do it 'does not do anything if ARC is *not* required' do
@spec.requires_arc = false @spec.requires_arc = false
@spec.ios.deployment_target = '5' @spec.ios.deployment_target = '5'
@spec.osx.deployment_target = '10.6' @spec.osx.deployment_target = '10.6'
...@@ -203,7 +202,7 @@ module Pod ...@@ -203,7 +202,7 @@ module Pod
osx_flags.should.not.include '-DOS_OBJECT_USE_OBJC' osx_flags.should.not.include '-DOS_OBJECT_USE_OBJC'
end end
it "does *not* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and has a deployment target of >= iOS 6.0 or OS X 10.8" do it 'does *not* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and has a deployment target of >= iOS 6.0 or OS X 10.8' do
@spec.requires_arc = false @spec.requires_arc = false
@spec.ios.deployment_target = '6' @spec.ios.deployment_target = '6'
@spec.osx.deployment_target = '10.8' @spec.osx.deployment_target = '10.8'
...@@ -213,7 +212,7 @@ module Pod ...@@ -213,7 +212,7 @@ module Pod
osx_flags.should.not.include '-DOS_OBJECT_USE_OBJC' osx_flags.should.not.include '-DOS_OBJECT_USE_OBJC'
end end
it "*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required but has a deployment target < iOS 6.0 or OS X 10.8" do it '*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required but has a deployment target < iOS 6.0 or OS X 10.8' do
@spec.requires_arc = true @spec.requires_arc = true
@spec.ios.deployment_target = '5.1' @spec.ios.deployment_target = '5.1'
@spec.osx.deployment_target = '10.7.2' @spec.osx.deployment_target = '10.7.2'
...@@ -223,7 +222,7 @@ module Pod ...@@ -223,7 +222,7 @@ module Pod
osx_flags.should.include '-DOS_OBJECT_USE_OBJC' osx_flags.should.include '-DOS_OBJECT_USE_OBJC'
end end
it "*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and *no* deployment target is specified" do it '*does* disable the `OS_OBJECT_USE_OBJC` flag if ARC is required and *no* deployment target is specified' do
@spec.requires_arc = true @spec.requires_arc = true
ios_flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) ios_flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
osx_flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:osx)) osx_flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:osx))
......
...@@ -29,14 +29,14 @@ module Pod ...@@ -29,14 +29,14 @@ module Pod
@installer = Installer::TargetInstaller.new(config.sandbox, @pod_target) @installer = Installer::TargetInstaller.new(config.sandbox, @pod_target)
end end
it "Adds the architectures to the custom build configurations of the user target" do it 'Adds the architectures to the custom build configurations of the user target' do
@pod_target.archs = "$(ARCHS_STANDARD_64_BIT)" @pod_target.archs = '$(ARCHS_STANDARD_64_BIT)'
@installer.send(:add_target) @installer.send(:add_target)
@installer.send(:target).resolved_build_setting('ARCHS').should == { @installer.send(:target).resolved_build_setting('ARCHS').should == {
"Release"=>"$(ARCHS_STANDARD_64_BIT)", 'Release' => '$(ARCHS_STANDARD_64_BIT)',
"Debug"=>"$(ARCHS_STANDARD_64_BIT)", 'Debug' => '$(ARCHS_STANDARD_64_BIT)',
"AppStore"=>"$(ARCHS_STANDARD_64_BIT)", 'AppStore' => '$(ARCHS_STANDARD_64_BIT)',
"Test"=>"$(ARCHS_STANDARD_64_BIT)" 'Test' => '$(ARCHS_STANDARD_64_BIT)',
} }
end end
......
...@@ -14,9 +14,9 @@ module Pod ...@@ -14,9 +14,9 @@ module Pod
@pod_bundle.user_project_path = project_path @pod_bundle.user_project_path = project_path
@pod_bundle.client_root = project_path.dirname @pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid] @pod_bundle.user_target_uuids = [@target.uuid]
configuration = Xcodeproj::Config.new({ configuration = Xcodeproj::Config.new(
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1'
}) )
@pod_bundle.xcconfigs['Debug'] = configuration @pod_bundle.xcconfigs['Debug'] = configuration
@pod_bundle.xcconfigs['Test'] = configuration @pod_bundle.xcconfigs['Test'] = configuration
@pod_bundle.xcconfigs['Release'] = configuration @pod_bundle.xcconfigs['Release'] = configuration
...@@ -50,7 +50,5 @@ module Pod ...@@ -50,7 +50,5 @@ module Pod
config.base_configuration_reference.should.equal existing config.base_configuration_reference.should.equal existing
end end
end end
end end
...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../../../spec_helper', __FILE__)
module Pod module Pod
describe TargetIntegrator = Installer::UserProjectIntegrator::TargetIntegrator do describe TargetIntegrator = Installer::UserProjectIntegrator::TargetIntegrator do
describe "In general" do describe 'In general' do
# The project contains a `PBXReferenceProxy` in the build files of the # The project contains a `PBXReferenceProxy` in the build files of the
# frameworks build phase which implicitly checks for the robustness of # frameworks build phase which implicitly checks for the robustness of
...@@ -19,9 +19,9 @@ module Pod ...@@ -19,9 +19,9 @@ module Pod
@pod_bundle.user_project_path = project_path @pod_bundle.user_project_path = project_path
@pod_bundle.client_root = project_path.dirname @pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid] @pod_bundle.user_target_uuids = [@target.uuid]
configuration = Xcodeproj::Config.new({ configuration = Xcodeproj::Config.new(
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1'
}) )
@pod_bundle.xcconfigs['Debug'] = configuration @pod_bundle.xcconfigs['Debug'] = configuration
@pod_bundle.xcconfigs['Test'] = configuration @pod_bundle.xcconfigs['Test'] = configuration
@pod_bundle.xcconfigs['Release'] = configuration @pod_bundle.xcconfigs['Release'] = configuration
...@@ -43,28 +43,28 @@ module Pod ...@@ -43,28 +43,28 @@ module Pod
it 'adds references to the Pods static libraries to the Frameworks group' do it 'adds references to the Pods static libraries to the Frameworks group' do
@target_integrator.integrate! @target_integrator.integrate!
@target_integrator.send(:user_project)["Frameworks/libPods.a"].should.not == nil @target_integrator.send(:user_project)['Frameworks/libPods.a'].should.not.nil?
end end
it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase = target.frameworks_build_phase phase = target.frameworks_build_phase
ref = phase.files.find { |f| f.file_ref.path == 'libPods.a'} ref = phase.files.find { |f| f.file_ref.path == 'libPods.a' }
ref.should.not.be.nil ref.should.not.be.nil
end end
it 'adds a Copy Pods Resources build phase to each target' do it 'adds a Copy Pods Resources build phase to each target' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == "Copy Pods Resources" } phase = target.shell_script_build_phases.find { |bp| bp.name == 'Copy Pods Resources' }
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\"" phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\""
end end
it 'adds a Check Manifest.lock build phase to each target' do it 'adds a Check Manifest.lock build phase to each target' do
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
phase = target.shell_script_build_phases.find { |bp| bp.name == "Check Pods Manifest.lock" } phase = target.shell_script_build_phases.find { |bp| bp.name == 'Check Pods Manifest.lock' }
phase.shell_script.should == <<-EOS.strip_heredoc phase.shell_script.should == <<-EOS.strip_heredoc
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [[ $? != 0 ]] ; then if [[ $? != 0 ]] ; then
...@@ -80,7 +80,7 @@ module Pod ...@@ -80,7 +80,7 @@ module Pod
@target_integrator.integrate! @target_integrator.integrate!
target = @target_integrator.send(:native_targets).first target = @target_integrator.send(:native_targets).first
target.build_phases.first target.build_phases.first
phase = target.build_phases.find { |bp| bp.name == "Check Pods Manifest.lock" } phase = target.build_phases.find { |bp| bp.name == 'Check Pods Manifest.lock' }
target.build_phases.first.should.equal? phase target.build_phases.first.should.equal? phase
end end
...@@ -95,7 +95,7 @@ module Pod ...@@ -95,7 +95,7 @@ module Pod
describe 'Private helpers' do describe 'Private helpers' do
it 'returns the native targets associated with the Pod bundle' do it 'returns the native targets associated with the Pod bundle' do
@target_integrator.send(:native_targets).map(&:name).should == %w[ SampleProject ] @target_integrator.send(:native_targets).map(&:name).should == %w( SampleProject )
end end
it 'returns the targets that need to be integrated' do it 'returns the targets that need to be integrated' do
...@@ -110,7 +110,7 @@ module Pod ...@@ -110,7 +110,7 @@ module Pod
build_file.file_ref = @project.new(Xcodeproj::Project::PBXVariantGroup) build_file.file_ref = @project.new(Xcodeproj::Project::PBXVariantGroup)
@target_integrator.stubs(:user_project).returns(@project) @target_integrator.stubs(:user_project).returns(@project)
@target.frameworks_build_phase.files << build_file @target.frameworks_build_phase.files << build_file
@target_integrator.send(:native_targets).map(&:name).should == %w[ SampleProject ] @target_integrator.send(:native_targets).map(&:name).should == %w( SampleProject )
end end
it 'is robust against build files with missing file references' do it 'is robust against build files with missing file references' do
...@@ -118,7 +118,7 @@ module Pod ...@@ -118,7 +118,7 @@ module Pod
build_file.file_ref = nil build_file.file_ref = nil
@target_integrator.stubs(:user_project).returns(@project) @target_integrator.stubs(:user_project).returns(@project)
@target.frameworks_build_phase.files << build_file @target.frameworks_build_phase.files << build_file
@target_integrator.send(:native_targets).map(&:name).should == %w[ SampleProject ] @target_integrator.send(:native_targets).map(&:name).should == %w( SampleProject )
end end
end end
end end
......
...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe UserProjectIntegrator = Installer::UserProjectIntegrator do describe UserProjectIntegrator = Installer::UserProjectIntegrator do
describe "In general" do describe 'In general' do
before do before do
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') @sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
...@@ -28,12 +28,12 @@ module Pod ...@@ -28,12 +28,12 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "In general" do describe 'In general' do
before do before do
@integrator.stubs(:warn_about_xcconfig_overrides) @integrator.stubs(:warn_about_xcconfig_overrides)
end end
it "adds the Pods project to the workspace" do it 'adds the Pods project to the workspace' do
UserProjectIntegrator::TargetIntegrator.any_instance.stubs(:integrate!) UserProjectIntegrator::TargetIntegrator.any_instance.stubs(:integrate!)
@integrator.integrate! @integrator.integrate!
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
...@@ -44,12 +44,12 @@ module Pod ...@@ -44,12 +44,12 @@ module Pod
pods_project_ref.should.not.be.nil pods_project_ref.should.not.be.nil
end end
it "integrates the user targets" do it 'integrates the user targets' do
UserProjectIntegrator::TargetIntegrator.any_instance.expects(:integrate!) UserProjectIntegrator::TargetIntegrator.any_instance.expects(:integrate!)
@integrator.integrate! @integrator.integrate!
end end
it "warns if the podfile does not contain any dependency" do it 'warns if the podfile does not contain any dependency' do
Podfile::TargetDefinition.any_instance.stubs(:empty?).returns(true) Podfile::TargetDefinition.any_instance.stubs(:empty?).returns(true)
@integrator.integrate! @integrator.integrate!
UI.warnings.should.include?('The Podfile does not contain any dependencies') UI.warnings.should.include?('The Podfile does not contain any dependencies')
...@@ -61,7 +61,7 @@ module Pod ...@@ -61,7 +61,7 @@ module Pod
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@library.stubs(:user_targets).returns([user_target]) @library.stubs(:user_targets).returns([user_target])
@library.xcconfigs['Release'] = {'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1'} @library.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library])
@integrator.unstub(:warn_about_xcconfig_overrides) @integrator.unstub(:warn_about_xcconfig_overrides)
...@@ -76,7 +76,7 @@ module Pod ...@@ -76,7 +76,7 @@ module Pod
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@library.stubs(:user_targets).returns([user_target]) @library.stubs(:user_targets).returns([user_target])
@library.xcconfigs['Release'] = {'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1'} @library.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library])
@integrator.unstub(:warn_about_xcconfig_overrides) @integrator.unstub(:warn_about_xcconfig_overrides)
...@@ -88,19 +88,19 @@ module Pod ...@@ -88,19 +88,19 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "Workspace creation" do describe 'Workspace creation' do
it "creates a new workspace if needed" do it 'creates a new workspace if needed' do
@integrator.send(:create_workspace) @integrator.send(:create_workspace)
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
"SampleProject/SampleProject.xcodeproj", 'SampleProject/SampleProject.xcodeproj',
"Pods/Pods.xcodeproj" 'Pods/Pods.xcodeproj',
] ]
end end
it "updates an existing workspace if needed" do it 'updates an existing workspace if needed' do
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
ref = Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group') ref = Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group')
workspace = Xcodeproj::Workspace.new(ref) workspace = Xcodeproj::Workspace.new(ref)
...@@ -108,15 +108,15 @@ module Pod ...@@ -108,15 +108,15 @@ module Pod
@integrator.send(:create_workspace) @integrator.send(:create_workspace)
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
"SampleProject/SampleProject.xcodeproj", 'SampleProject/SampleProject.xcodeproj',
"Pods/Pods.xcodeproj" 'Pods/Pods.xcodeproj',
] ]
end end
it "doesn't write the workspace if not needed" do it "doesn't write the workspace if not needed" do
file_references = [ file_references = [
Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group'), Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group'),
Xcodeproj::Workspace::FileReference.new('Pods/Pods.xcodeproj', 'group') Xcodeproj::Workspace::FileReference.new('Pods/Pods.xcodeproj', 'group'),
] ]
workspace = Xcodeproj::Workspace.new(file_references) workspace = Xcodeproj::Workspace.new(file_references)
...@@ -126,7 +126,7 @@ module Pod ...@@ -126,7 +126,7 @@ module Pod
@integrator.send(:create_workspace) @integrator.send(:create_workspace)
end end
it "only appends projects to the workspace and never deletes one" do it 'only appends projects to the workspace and never deletes one' do
ref = Xcodeproj::Workspace::FileReference.new('user_added_project.xcodeproj', 'group') ref = Xcodeproj::Workspace::FileReference.new('user_added_project.xcodeproj', 'group')
workspace = Xcodeproj::Workspace.new(ref) workspace = Xcodeproj::Workspace.new(ref)
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
...@@ -135,12 +135,12 @@ module Pod ...@@ -135,12 +135,12 @@ module Pod
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
'user_added_project.xcodeproj', 'user_added_project.xcodeproj',
"SampleProject/SampleProject.xcodeproj", 'SampleProject/SampleProject.xcodeproj',
"Pods/Pods.xcodeproj" 'Pods/Pods.xcodeproj',
] ]
end end
it "preserves the order of the projects in the workspace" do it 'preserves the order of the projects in the workspace' do
file_references = [ file_references = [
Xcodeproj::Workspace::FileReference.new('Pods/Pods.xcodeproj', 'group'), Xcodeproj::Workspace::FileReference.new('Pods/Pods.xcodeproj', 'group'),
Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group'), Xcodeproj::Workspace::FileReference.new('SampleProject/SampleProject.xcodeproj', 'group'),
...@@ -152,8 +152,8 @@ module Pod ...@@ -152,8 +152,8 @@ module Pod
@integrator.send(:create_workspace) @integrator.send(:create_workspace)
saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path) saved = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
saved.file_references.map(&:path).should == [ saved.file_references.map(&:path).should == [
"Pods/Pods.xcodeproj", 'Pods/Pods.xcodeproj',
"SampleProject/SampleProject.xcodeproj", 'SampleProject/SampleProject.xcodeproj',
] ]
end end
...@@ -161,32 +161,32 @@ module Pod ...@@ -161,32 +161,32 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "Private Helpers" do describe 'Private Helpers' do
it "uses the path of the workspace defined in the podfile" do it 'uses the path of the workspace defined in the podfile' do
path = "a_path" path = 'a_path'
@podfile.workspace(path) @podfile.workspace(path)
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
workspace_path.to_s.should.end_with(path + ".xcworkspace") workspace_path.to_s.should.end_with(path + '.xcworkspace')
workspace_path.should.be.absolute workspace_path.should.be.absolute
workspace_path.class.should == Pathname workspace_path.class.should == Pathname
end end
it "names the workspace after the user project if needed" do it 'names the workspace after the user project if needed' do
@integrator.send(:workspace_path).should == temporary_directory + 'SampleProject.xcworkspace' @integrator.send(:workspace_path).should == temporary_directory + 'SampleProject.xcworkspace'
end end
it "raises if no workspace could be selected" do it 'raises if no workspace could be selected' do
@integrator.expects(:user_project_paths).returns(%w[ project1 project2 ]) @integrator.expects(:user_project_paths).returns(%w( project1 project2 ))
e = lambda { @integrator.send(:workspace_path) }.should.raise Informative e = lambda { @integrator.send(:workspace_path) }.should.raise Informative
end end
it "returns the paths of the user projects" do it 'returns the paths of the user projects' do
@integrator.send(:user_project_paths).should == [ @sample_project_path ] @integrator.send(:user_project_paths).should == [@sample_project_path]
end end
it "skips libraries with empty target definitions" do it 'skips libraries with empty target definitions' do
@integrator.targets.map(&:name).should == ["Pods", "Pods-empty"] @integrator.targets.map(&:name).should == ['Pods', 'Pods-empty']
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods'] @integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
end end
......
...@@ -45,7 +45,7 @@ module Pod ...@@ -45,7 +45,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "In general" do describe 'In general' do
before do before do
@installer.stubs(:resolve_dependencies) @installer.stubs(:resolve_dependencies)
...@@ -56,7 +56,7 @@ module Pod ...@@ -56,7 +56,7 @@ module Pod
@installer.stubs(:perform_post_install_actions) @installer.stubs(:perform_post_install_actions)
end end
it "in runs the pre-install hooks before cleaning the Pod sources" do it 'in runs the pre-install hooks before cleaning the Pod sources' do
@installer.unstub(:download_dependencies) @installer.unstub(:download_dependencies)
@installer.stubs(:create_file_accessors) @installer.stubs(:create_file_accessors)
@installer.stubs(:install_pod_sources) @installer.stubs(:install_pod_sources)
...@@ -69,7 +69,7 @@ module Pod ...@@ -69,7 +69,7 @@ module Pod
@installer.install! @installer.install!
end end
it "in runs the post-install hooks before serializing the Pods project" do it 'in runs the post-install hooks before serializing the Pods project' do
@installer.stubs(:prepare_pods_project) @installer.stubs(:prepare_pods_project)
@installer.stubs(:run_pre_install_hooks) @installer.stubs(:run_pre_install_hooks)
@installer.stubs(:install_file_references) @installer.stubs(:install_file_references)
...@@ -87,7 +87,7 @@ module Pod ...@@ -87,7 +87,7 @@ module Pod
@installer.install! @installer.install!
end end
it "integrates the user targets if the corresponding config is set" do it 'integrates the user targets if the corresponding config is set' do
config.integrate_targets = true config.integrate_targets = true
@installer.expects(:integrate_user_project) @installer.expects(:integrate_user_project)
@installer.install! @installer.install!
...@@ -116,28 +116,28 @@ module Pod ...@@ -116,28 +116,28 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Dependencies Resolution" do describe 'Dependencies Resolution' do
describe "#analyze" do describe '#analyze' do
it "prints a warning if the version of the Lockfile is higher than the one of the executable" do it 'prints a warning if the version of the Lockfile is higher than the one of the executable' do
Lockfile.any_instance.stubs(:cocoapods_version).returns(Version.new('999')) Lockfile.any_instance.stubs(:cocoapods_version).returns(Version.new('999'))
STDERR.expects(:puts) STDERR.expects(:puts)
@installer.send(:analyze) @installer.send(:analyze)
end end
it "analyzes the Podfile, the Lockfile and the Sandbox" do it 'analyzes the Podfile, the Lockfile and the Sandbox' do
@installer.send(:analyze) @installer.send(:analyze)
@installer.analysis_result.sandbox_state.added.should == ["JSONKit"] @installer.analysis_result.sandbox_state.added.should == ['JSONKit']
end end
it "stores the targets created by the analyzer" do it 'stores the targets created by the analyzer' do
@installer.send(:analyze) @installer.send(:analyze)
@installer.aggregate_targets.map(&:name).sort.should == ['Pods'] @installer.aggregate_targets.map(&:name).sort.should == ['Pods']
@installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit'] @installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit']
end end
it "configures the analyzer to use update mode if appropriate" do it 'configures the analyzer to use update mode if appropriate' do
@installer.update = true @installer.update = true
Installer::Analyzer.any_instance.expects(:update=).with(true) Installer::Analyzer.any_instance.expects(:update=).with(true)
@installer.send(:analyze) @installer.send(:analyze)
...@@ -149,7 +149,7 @@ module Pod ...@@ -149,7 +149,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#validate_whitelisted_configurations" do describe '#validate_whitelisted_configurations' do
it "raises when a whitelisted configuration doesn’t exist in the user's project" do it "raises when a whitelisted configuration doesn’t exist in the user's project" do
target_definition = @installer.podfile.target_definitions.values.first target_definition = @installer.podfile.target_definitions.values.first
target_definition.whitelist_pod_for_configuration('JSONKit', 'YOLO') target_definition.whitelist_pod_for_configuration('JSONKit', 'YOLO')
...@@ -171,18 +171,18 @@ module Pod ...@@ -171,18 +171,18 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#clean_sandbox" do describe '#clean_sandbox' do
before do before do
@analysis_result = Installer::Analyzer::AnalysisResult.new @analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = [] @analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new() @analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new
@pod_targets = [PodTarget.new([], nil, config.sandbox)] @pod_targets = [PodTarget.new([], nil, config.sandbox)]
@installer.stubs(:analysis_result).returns(@analysis_result) @installer.stubs(:analysis_result).returns(@analysis_result)
@installer.stubs(:pod_targets).returns(@pod_targets) @installer.stubs(:pod_targets).returns(@pod_targets)
end end
it "cleans the header stores" do it 'cleans the header stores' do
config.sandbox.public_headers.expects(:implode!) config.sandbox.public_headers.expects(:implode!)
@installer.pod_targets.each do |pods_target| @installer.pod_targets.each do |pods_target|
pods_target.build_headers.expects(:implode!) pods_target.build_headers.expects(:implode!)
...@@ -190,7 +190,7 @@ module Pod ...@@ -190,7 +190,7 @@ module Pod
@installer.send(:clean_sandbox) @installer.send(:clean_sandbox)
end end
it "deletes the sources of the removed Pods" do it 'deletes the sources of the removed Pods' do
@analysis_result.sandbox_state.add_name('Deleted-Pod', :deleted) @analysis_result.sandbox_state.add_name('Deleted-Pod', :deleted)
config.sandbox.expects(:clean_pod).with('Deleted-Pod') config.sandbox.expects(:clean_pod).with('Deleted-Pod')
@installer.send(:clean_sandbox) @installer.send(:clean_sandbox)
...@@ -202,11 +202,11 @@ module Pod ...@@ -202,11 +202,11 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Downloading dependencies" do describe 'Downloading dependencies' do
describe "#install_pod_sources" do describe '#install_pod_sources' do
it "installs all the Pods which are marked as needing installation" do it 'installs all the Pods which are marked as needing installation' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
spec_2 = Spec.new spec_2 = Spec.new
spec_2.name = 'RestKit' spec_2.name = 'RestKit'
...@@ -220,7 +220,7 @@ module Pod ...@@ -220,7 +220,7 @@ module Pod
@installer.send(:install_pod_sources) @installer.send(:install_pod_sources)
end end
it "correctly configures the Pod source installer" do it 'correctly configures the Pod source installer' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = PodTarget.new([spec], nil, config.sandbox)
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
...@@ -230,7 +230,7 @@ module Pod ...@@ -230,7 +230,7 @@ module Pod
@installer.send(:install_source_of_pod, 'BananaLib') @installer.send(:install_source_of_pod, 'BananaLib')
end end
it "maintains the list of the installed specs" do it 'maintains the list of the installed specs' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = PodTarget.new([spec], nil, config.sandbox)
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
...@@ -241,7 +241,7 @@ module Pod ...@@ -241,7 +241,7 @@ 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 it 'prints the previous version of a pod while updating the spec' do
spec = Spec.new spec = Spec.new
spec.name = 'RestKit' spec.name = 'RestKit'
spec.version = '2.0' spec.version = '2.0'
...@@ -259,9 +259,9 @@ module Pod ...@@ -259,9 +259,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#clean" do describe '#clean' do
it "it cleans only if the config instructs to do it" do it 'it cleans only if the config instructs to do it' do
config.clean = false config.clean = false
@installer.send(:clean_pod_sources) @installer.send(:clean_pod_sources)
Installer::PodSourceInstaller.any_instance.expects(:install!).never Installer::PodSourceInstaller.any_instance.expects(:install!).never
...@@ -276,9 +276,9 @@ module Pod ...@@ -276,9 +276,9 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Generating pods project" do describe 'Generating pods project' do
describe "#prepare_pods_project" do describe '#prepare_pods_project' do
before do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
...@@ -291,26 +291,26 @@ module Pod ...@@ -291,26 +291,26 @@ module Pod
@installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test'] @installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test']
end end
it "sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project" do it 'sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project' do
config.integrate_targets = true config.integrate_targets = true
@installer.send(:analyze) @installer.send(:analyze)
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.build_settings('Debug')["STRIP_INSTALLED_PRODUCT"].should == "NO" @installer.pods_project.build_settings('Debug')['STRIP_INSTALLED_PRODUCT'].should == 'NO'
@installer.pods_project.build_settings('Test')["STRIP_INSTALLED_PRODUCT"].should == "NO" @installer.pods_project.build_settings('Test')['STRIP_INSTALLED_PRODUCT'].should == 'NO'
@installer.pods_project.build_settings('Release')["STRIP_INSTALLED_PRODUCT"].should == "NO" @installer.pods_project.build_settings('Release')['STRIP_INSTALLED_PRODUCT'].should == 'NO'
@installer.pods_project.build_settings('App Store')["STRIP_INSTALLED_PRODUCT"].should == "NO" @installer.pods_project.build_settings('App Store')['STRIP_INSTALLED_PRODUCT'].should == 'NO'
end end
before do before do
@installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {})) @installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {}))
end end
it "creates the Pods project" do it 'creates the Pods project' do
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@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 it 'preserves Pod paths specified as absolute or rooted to home' do
local_podfile = generate_local_podfile local_podfile = generate_local_podfile
local_installer = Installer.new(config.sandbox, local_podfile) local_installer = Installer.new(config.sandbox, local_podfile)
local_installer.send(:analyze) local_installer.send(:analyze)
...@@ -319,13 +319,13 @@ module Pod ...@@ -319,13 +319,13 @@ module Pod
Pathname.new(group.path).should.be.absolute Pathname.new(group.path).should.be.absolute
end 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)
@installer.pods_project['Podfile'].should.be.not.nil @installer.pods_project['Podfile'].should.be.not.nil
end end
it "sets the deployment target for the whole project" do it 'sets the deployment target for the whole project' do
pod_target_ios = PodTarget.new([], nil, config.sandbox) pod_target_ios = PodTarget.new([], nil, config.sandbox)
pod_target_osx = PodTarget.new([], nil, config.sandbox) pod_target_osx = PodTarget.new([], nil, config.sandbox)
pod_target_ios.stubs(:platform).returns(Platform.new(:ios, '6.0')) pod_target_ios.stubs(:platform).returns(Platform.new(:ios, '6.0'))
...@@ -335,8 +335,8 @@ module Pod ...@@ -335,8 +335,8 @@ module Pod
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
build_settings = @installer.pods_project.build_configurations.map(&:build_settings) build_settings = @installer.pods_project.build_configurations.map(&:build_settings)
build_settings.each do |build_setting| build_settings.each do |build_setting|
build_setting["MACOSX_DEPLOYMENT_TARGET"].should == '10.8' build_setting['MACOSX_DEPLOYMENT_TARGET'].should == '10.8'
build_setting["IPHONEOS_DEPLOYMENT_TARGET"].should == '6.0' build_setting['IPHONEOS_DEPLOYMENT_TARGET'].should == '6.0'
end end
end end
...@@ -344,9 +344,9 @@ module Pod ...@@ -344,9 +344,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#install_file_references" do describe '#install_file_references' do
it "installs the file references" do it 'installs the file references' do
@installer.stubs(:pod_targets).returns([]) @installer.stubs(:pod_targets).returns([])
Installer::FileReferencesInstaller.any_instance.expects(:install!) Installer::FileReferencesInstaller.any_instance.expects(:install!)
@installer.send(:install_file_references) @installer.send(:install_file_references)
...@@ -356,9 +356,9 @@ module Pod ...@@ -356,9 +356,9 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#install_libraries" do describe '#install_libraries' do
it "install the targets of the Pod project" do it 'install the targets of the Pod project' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.store_pod('BananaLib') target_definition.store_pod('BananaLib')
...@@ -369,7 +369,7 @@ module Pod ...@@ -369,7 +369,7 @@ module Pod
@installer.send(:install_libraries) @installer.send(:install_libraries)
end end
it "skips empty pod targets" do it 'skips empty pod targets' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox) pod_target = PodTarget.new([spec], target_definition, config.sandbox)
...@@ -383,24 +383,24 @@ module Pod ...@@ -383,24 +383,24 @@ module Pod
Specification::Consumer.any_instance.stubs(:frameworks).returns(['QuartzCore']) Specification::Consumer.any_instance.stubs(:frameworks).returns(['QuartzCore'])
@installer.install! @installer.install!
names = @installer.sandbox.project['Frameworks'].children.map(&:name) names = @installer.sandbox.project['Frameworks'].children.map(&:name)
names.sort.should == ["Foundation.framework", "QuartzCore.framework"] names.sort.should == ['Foundation.framework', 'QuartzCore.framework']
end end
end end
#--------------------------------------# #--------------------------------------#
describe "#set_target_dependencies" do describe '#set_target_dependencies' do
xit "sets the pod targets as dependencies of the aggregate target" do xit 'sets the pod targets as dependencies of the aggregate target' do
end end
xit "sets the dependecies of the pod targets" do xit 'sets the dependecies of the pod targets' do
end end
xit "is robusts against subspecs" do xit 'is robusts against subspecs' do
end end
...@@ -408,7 +408,7 @@ module Pod ...@@ -408,7 +408,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#write_pod_project" do describe '#write_pod_project' do
before do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
...@@ -416,13 +416,13 @@ module Pod ...@@ -416,13 +416,13 @@ module Pod
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
end end
it "recursively sorts the project" do it 'recursively sorts the project' do
Xcodeproj::Project.any_instance.stubs(:recreate_user_schemes) Xcodeproj::Project.any_instance.stubs(:recreate_user_schemes)
@installer.pods_project.main_group.expects(:sort) @installer.pods_project.main_group.expects(:sort)
@installer.send(:write_pod_project) @installer.send(:write_pod_project)
end end
it "saves the project to the given path" do it 'saves the project to the given path' do
Xcodeproj::Project.any_instance.stubs(:recreate_user_schemes) Xcodeproj::Project.any_instance.stubs(:recreate_user_schemes)
path = temporary_directory + 'Pods/Pods.xcodeproj' path = temporary_directory + 'Pods/Pods.xcodeproj'
@installer.pods_project.expects(:save) @installer.pods_project.expects(:save)
...@@ -433,7 +433,7 @@ module Pod ...@@ -433,7 +433,7 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#write_lockfiles" do describe '#write_lockfiles' do
before do before do
@analysis_result = Installer::Analyzer::AnalysisResult.new @analysis_result = Installer::Analyzer::AnalysisResult.new
...@@ -441,18 +441,18 @@ module Pod ...@@ -441,18 +441,18 @@ module Pod
@installer.stubs(:analysis_result).returns(@analysis_result) @installer.stubs(:analysis_result).returns(@analysis_result)
end end
it "generates the lockfile" do it 'generates the lockfile' do
@installer.send(:write_lockfiles) @installer.send(:write_lockfiles)
@installer.lockfile.pod_names.should == ['BananaLib'] @installer.lockfile.pod_names.should == ['BananaLib']
end end
it "writes the lockfile" do it 'writes the lockfile' do
@installer.send(:write_lockfiles) @installer.send(:write_lockfiles)
lockfile = Lockfile.from_file(temporary_directory + 'Podfile.lock') lockfile = Lockfile.from_file(temporary_directory + 'Podfile.lock')
lockfile.pod_names.should == ['BananaLib'] lockfile.pod_names.should == ['BananaLib']
end end
it "writes the sandbox manifest" do it 'writes the sandbox manifest' do
@installer.send(:write_lockfiles) @installer.send(:write_lockfiles)
lockfile = Lockfile.from_file(temporary_directory + 'Pods/Manifest.lock') lockfile = Lockfile.from_file(temporary_directory + 'Pods/Manifest.lock')
lockfile.pod_names.should == ['BananaLib'] lockfile.pod_names.should == ['BananaLib']
...@@ -464,9 +464,9 @@ module Pod ...@@ -464,9 +464,9 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Integrating client projects" do describe 'Integrating client projects' do
it "integrates the client projects" do it 'integrates the client projects' do
@installer.stubs(:aggregate_targets).returns([AggregateTarget.new(nil, config.sandbox)]) @installer.stubs(:aggregate_targets).returns([AggregateTarget.new(nil, config.sandbox)])
Installer::UserProjectIntegrator.any_instance.expects(:integrate!) Installer::UserProjectIntegrator.any_instance.expects(:integrate!)
@installer.send(:integrate_user_project) @installer.send(:integrate_user_project)
...@@ -474,7 +474,7 @@ module Pod ...@@ -474,7 +474,7 @@ module Pod
end end
describe "Plugins Hooks" do describe 'Plugins Hooks' do
before do before do
@installer.send(:analyze) @installer.send(:analyze)
@specs = @installer.pod_targets.map(&:specs).flatten @specs = @installer.pod_targets.map(&:specs).flatten
...@@ -482,8 +482,8 @@ module Pod ...@@ -482,8 +482,8 @@ module Pod
@installer.stubs(:installed_specs).returns(@specs) @installer.stubs(:installed_specs).returns(@specs)
end end
it "runs plugins post install hook" do it 'runs plugins post install hook' do
context = stub() context = stub
Installer::HooksContext.expects(:generate).returns(context) Installer::HooksContext.expects(:generate).returns(context)
HooksManager.expects(:run).with(:post_install, context) HooksManager.expects(:run).with(:post_install, context)
@installer.send(:run_plugins_post_install_hooks) @installer.send(:run_plugins_post_install_hooks)
...@@ -492,7 +492,7 @@ module Pod ...@@ -492,7 +492,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Hooks" do describe 'Hooks' do
before do before do
@installer.send(:analyze) @installer.send(:analyze)
...@@ -502,47 +502,47 @@ module Pod ...@@ -502,47 +502,47 @@ module Pod
@aggregate_target = @installer.aggregate_targets.first @aggregate_target = @installer.aggregate_targets.first
end end
it "runs the pre install hooks" do it 'runs the pre install hooks' do
installer_rep = stub() installer_rep = stub
pod_rep = stub() pod_rep = stub
library_rep = stub() library_rep = stub
@installer.expects(:installer_rep).returns(installer_rep) @installer.expects(:installer_rep).returns(installer_rep)
@installer.podfile.expects(:pre_install!).with(installer_rep) @installer.podfile.expects(:pre_install!).with(installer_rep)
@installer.send(:run_pre_install_hooks) @installer.send(:run_pre_install_hooks)
end end
it "run_podfile_post_install_hooks" do it 'run_podfile_post_install_hooks' do
installer_rep = stub() installer_rep = stub
target_installer_data = stub() target_installer_data = stub
@installer.expects(:installer_rep).returns(installer_rep) @installer.expects(:installer_rep).returns(installer_rep)
@installer.podfile.expects(:post_install!).with(installer_rep) @installer.podfile.expects(:post_install!).with(installer_rep)
@installer.send(:run_podfile_post_install_hooks) @installer.send(:run_podfile_post_install_hooks)
end end
it "calls the hooks in the specs for each target" do it 'calls the hooks in the specs for each target' do
pod_target_ios = PodTarget.new([@spec], nil, config.sandbox) pod_target_ios = PodTarget.new([@spec], nil, config.sandbox)
pod_target_osx = PodTarget.new([@spec], nil, config.sandbox) pod_target_osx = PodTarget.new([@spec], nil, config.sandbox)
pod_target_ios.stubs(:name).returns('label') pod_target_ios.stubs(:name).returns('label')
pod_target_osx.stubs(:name).returns('label') pod_target_osx.stubs(:name).returns('label')
library_ios_rep = stub() library_ios_rep = stub
library_osx_rep = stub() library_osx_rep = stub
target_installer_data = stub() target_installer_data = stub
@installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx]) @installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx])
@installer.stubs(:installer_rep).returns(stub()) @installer.stubs(:installer_rep).returns(stub)
@installer.podfile.expects(:pre_install!) @installer.podfile.expects(:pre_install!)
@installer.send(:run_pre_install_hooks) @installer.send(:run_pre_install_hooks)
@installer.send(:run_podfile_post_install_hooks) @installer.send(:run_podfile_post_install_hooks)
end end
it "returns the hook representation of the installer" do it 'returns the hook representation of the installer' do
rep = @installer.send(:installer_rep) rep = @installer.send(:installer_rep)
rep.sandbox_root.should == @installer.sandbox.root rep.sandbox_root.should == @installer.sandbox.root
end end
it "returns the hook representation of a pod" do it 'returns the hook representation of a pod' do
file_accessor = stub(:spec => @spec) file_accessor = stub(:spec => @spec)
@aggregate_target.pod_targets.first.stubs(:file_accessors).returns([file_accessor]) @aggregate_target.pod_targets.first.stubs(:file_accessors).returns([file_accessor])
rep = @installer.send(:pod_rep, 'JSONKit') rep = @installer.send(:pod_rep, 'JSONKit')
...@@ -550,26 +550,25 @@ module Pod ...@@ -550,26 +550,25 @@ module Pod
rep.root_spec.should == @spec rep.root_spec.should == @spec
end end
it "returns the hook representation of an aggregate target" do it 'returns the hook representation of an aggregate target' do
rep = @installer.send(:library_rep, @aggregate_target) rep = @installer.send(:library_rep, @aggregate_target)
rep.send(:library).name.should == 'Pods' rep.send(:library).name.should == 'Pods'
end end
it "returns the hook representation of all the pods" do it 'returns the hook representation of all the pods' do
reps = @installer.send(:pod_reps) reps = @installer.send(:pod_reps)
reps.map(&:name).should == ['JSONKit'] reps.map(&:name).should == ['JSONKit']
end end
it "returns the hook representation of all the aggregate target" do it 'returns the hook representation of all the aggregate target' do
reps = @installer.send(:library_reps) reps = @installer.send(:library_reps)
reps.map(&:name).sort.should == ['Pods'].sort reps.map(&:name).sort.should == ['Pods'].sort
end end
it "returns the aggregate targets which use a given Pod" do it 'returns the aggregate targets which use a given Pod' do
libs = @installer.send(:libraries_using_spec, @spec) libs = @installer.send(:libraries_using_spec, @spec)
libs.map(&:name).should == ['Pods'] libs.map(&:name).should == ['Pods']
end end
end end
end end
end end
...@@ -3,31 +3,31 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,31 +3,31 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Pod::AggregateTarget do describe Pod::AggregateTarget do
describe "In general" do describe 'In general' do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@lib = AggregateTarget.new(@target_definition, config.sandbox) @lib = AggregateTarget.new(@target_definition, config.sandbox)
end end
it "returns the target_definition that generated it" do it 'returns the target_definition that generated it' do
@lib.target_definition.should == @target_definition @lib.target_definition.should == @target_definition
end end
it "returns the label of the target definition" do it 'returns the label of the target definition' do
@lib.label.should == 'Pods' @lib.label.should == 'Pods'
end end
it "returns its name" do it 'returns its name' do
@lib.name.should == 'Pods' @lib.name.should == 'Pods'
end end
it "returns the name of its product" do it 'returns the name of its product' do
@lib.product_name.should == 'libPods.a' @lib.product_name.should == 'libPods.a'
end end
end end
describe "Support files" do describe 'Support files' do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
...@@ -35,38 +35,38 @@ module Pod ...@@ -35,38 +35,38 @@ module Pod
@lib.client_root = config.sandbox.root.dirname @lib.client_root = config.sandbox.root.dirname
end end
it "returns the absolute path of the xcconfig file" do it 'returns the absolute path of the xcconfig file' do
@lib.xcconfig_path("Release").to_s.should.include?('Pods/Pods.release.xcconfig') @lib.xcconfig_path('Release').to_s.should.include?('Pods/Pods.release.xcconfig')
end end
it "returns the absolute path of the resources script" do it 'returns the absolute path of the resources script' do
@lib.copy_resources_script_path.to_s.should.include?('Pods/Pods-resources.sh') @lib.copy_resources_script_path.to_s.should.include?('Pods/Pods-resources.sh')
end end
it "returns the absolute path of the target header file" do it 'returns the absolute path of the target header file' do
@lib.target_environment_header_path.to_s.should.include?('Pods/Pods-environment.h') @lib.target_environment_header_path.to_s.should.include?('Pods/Pods-environment.h')
end end
it "returns the absolute path of the prefix header file" do it 'returns the absolute path of the prefix header file' do
@lib.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch') @lib.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch')
end end
it "returns the absolute path of the bridge support file" do it 'returns the absolute path of the bridge support file' do
@lib.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport') @lib.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport')
end end
it "returns the absolute path of the acknowledgements files without extension" do it 'returns the absolute path of the acknowledgements files without extension' do
@lib.acknowledgements_basepath.to_s.should.include?('Pods/Pods-acknowledgements') @lib.acknowledgements_basepath.to_s.should.include?('Pods/Pods-acknowledgements')
end end
#--------------------------------------# #--------------------------------------#
it "returns the path of the resources script relative to the user project" do it 'returns the path of the resources script relative to the user project' do
@lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh' @lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh'
end end
it "returns the path of the xcconfig file relative to the user project" do it 'returns the path of the xcconfig file relative to the user project' do
@lib.xcconfig_relative_path("Release").should == 'Pods/Pods.release.xcconfig' @lib.xcconfig_relative_path('Release').should == 'Pods/Pods.release.xcconfig'
end end
end end
......
...@@ -9,17 +9,17 @@ module Pod ...@@ -9,17 +9,17 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "In general" do describe 'In general' do
it "creates the support files group on initialization" do it 'creates the support files group on initialization' do
@project.support_files_group.name.should == 'Targets Support Files' @project.support_files_group.name.should == 'Targets Support Files'
end end
it "creates the Pods group on initialization" do it 'creates the Pods group on initialization' do
@project.pods.name.should == 'Pods' @project.pods.name.should == 'Pods'
end end
it "creates the development Pods group on initialization" do it 'creates the development Pods group on initialization' do
@project.development_pods.name.should == 'Development Pods' @project.development_pods.name.should == 'Development Pods'
end end
...@@ -27,28 +27,28 @@ module Pod ...@@ -27,28 +27,28 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Pod Groups" do describe 'Pod Groups' do
describe "#add_pod_group" do describe '#add_pod_group' do
before do before do
@path = config.sandbox.pod_dir('BananaLib') @path = config.sandbox.pod_dir('BananaLib')
end end
it "adds the group for a Pod" do it 'adds the group for a Pod' do
group = @project.add_pod_group('BananaLib', @path) group = @project.add_pod_group('BananaLib', @path)
group.parent.should == @project.pods group.parent.should == @project.pods
group.name.should == 'BananaLib' group.name.should == 'BananaLib'
end end
it "adds the group for a development Pod" do it 'adds the group for a development Pod' do
path = config.sandbox.pod_dir('BananaLib') path = config.sandbox.pod_dir('BananaLib')
group = @project.add_pod_group('BananaLib', @path, true) group = @project.add_pod_group('BananaLib', @path, true)
group.parent.should == @project.development_pods group.parent.should == @project.development_pods
group.name.should == 'BananaLib' group.name.should == 'BananaLib'
end end
it "configures the path of a new Pod group" do it 'configures the path of a new Pod group' do
path = config.sandbox.pod_dir('BananaLib') path = config.sandbox.pod_dir('BananaLib')
group = @project.add_pod_group('BananaLib', @path) group = @project.add_pod_group('BananaLib', @path)
group.source_tree.should == '<group>' group.source_tree.should == '<group>'
...@@ -56,7 +56,7 @@ module Pod ...@@ -56,7 +56,7 @@ module Pod
Pathname.new(group.path).should.be.relative Pathname.new(group.path).should.be.relative
end end
it "configures the path of a new Pod group as absolute if requested" do it 'configures the path of a new Pod group as absolute if requested' do
path = config.sandbox.pod_dir('BananaLib') path = config.sandbox.pod_dir('BananaLib')
group = @project.add_pod_group('BananaLib', @path, false, true) group = @project.add_pod_group('BananaLib', @path, false, true)
group.source_tree.should == '<absolute>' group.source_tree.should == '<absolute>'
...@@ -68,40 +68,40 @@ module Pod ...@@ -68,40 +68,40 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#pod_groups" do describe '#pod_groups' do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib')) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'))
@project.add_pod_group('OrangeLib', config.sandbox.pod_dir('OrangeLib'), true) @project.add_pod_group('OrangeLib', config.sandbox.pod_dir('OrangeLib'), true)
end end
it "returns the pod groups" do it 'returns the pod groups' do
@project.pod_groups.map(&:name).sort.should == ["BananaLib", "OrangeLib"] @project.pod_groups.map(&:name).sort.should == %w(BananaLib OrangeLib)
end end
it "doesn't alters the original groups" do it "doesn't alters the original groups" do
@project.pods.children.map(&:name).sort.should == ["BananaLib"] @project.pods.children.map(&:name).sort.should == ['BananaLib']
@project.development_pods.children.map(&:name).sort.should == ["OrangeLib"] @project.development_pods.children.map(&:name).sort.should == ['OrangeLib']
end end
end end
#----------------------------------------# #----------------------------------------#
it "returns the group of a Pod with a given name" do it 'returns the group of a Pod with a given name' do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib')) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'))
@project.pod_group('BananaLib').name.should == 'BananaLib' @project.pod_group('BananaLib').name.should == 'BananaLib'
end end
#----------------------------------------# #----------------------------------------#
describe "#group_for_spec" do describe '#group_for_spec' do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib')) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'))
end end
it "returns the group for the spec with the given name" do it 'returns the group for the spec with the given name' do
group = @project.group_for_spec('BananaLib/Tree') group = @project.group_for_spec('BananaLib/Tree')
group.hierarchy_path.should == '/Pods/BananaLib/Tree' group.hierarchy_path.should == '/Pods/BananaLib/Tree'
end end
...@@ -112,7 +112,7 @@ module Pod ...@@ -112,7 +112,7 @@ module Pod
group_1.uuid.should == group_2.uuid group_1.uuid.should == group_2.uuid
end end
it "returns the subgroup with the given key" do it 'returns the subgroup with the given key' do
group = @project.group_for_spec('BananaLib/Tree', :resources) group = @project.group_for_spec('BananaLib/Tree', :resources)
group.hierarchy_path.should == '/Pods/BananaLib/Tree/Resources' group.hierarchy_path.should == '/Pods/BananaLib/Tree/Resources'
end end
...@@ -123,7 +123,7 @@ module Pod ...@@ -123,7 +123,7 @@ module Pod
group_1.uuid.should == group_2.uuid group_1.uuid.should == group_2.uuid
end end
it "raises if the subgroup key is unrecognized" do it 'raises if the subgroup key is unrecognized' do
should.raise ArgumentError do should.raise ArgumentError do
@project.group_for_spec('BananaLib/Tree', :bananaland) @project.group_for_spec('BananaLib/Tree', :bananaland)
end.message.should.match /Unrecognized.*key/ end.message.should.match /Unrecognized.*key/
...@@ -132,13 +132,13 @@ module Pod ...@@ -132,13 +132,13 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#pod_support_files_group" do describe '#pod_support_files_group' do
before do before do
@project.add_pod_group('BananaLib', @path, false, true) @project.add_pod_group('BananaLib', @path, false, true)
end end
it "creates a support file group relative to the project" do it 'creates a support file group relative to the project' do
group = @project.pod_support_files_group('BananaLib') group = @project.pod_support_files_group('BananaLib')
group.source_tree.should == 'SOURCE_ROOT' group.source_tree.should == 'SOURCE_ROOT'
group.path.should.be.nil group.path.should.be.nil
...@@ -155,17 +155,17 @@ module Pod ...@@ -155,17 +155,17 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "File references" do describe 'File references' do
describe "#reference_for_path" do describe '#reference_for_path' do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + "file.m" @file = config.sandbox.pod_dir('BananaLib') + 'file.m'
@group = @project.group_for_spec('BananaLib') @group = @project.group_for_spec('BananaLib')
end end
it "adds a file references to the given file" do it 'adds a file references to the given file' do
ref = @project.add_file_reference(@file, @group) ref = @project.add_file_reference(@file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/file.m' ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end end
...@@ -177,7 +177,7 @@ module Pod ...@@ -177,7 +177,7 @@ module Pod
@group.children.count.should == 1 @group.children.count.should == 1
end end
it "raises if the given path is not absolute" do it 'raises if the given path is not absolute' do
should.raise ArgumentError do should.raise ArgumentError do
@project.add_file_reference('relative/path/to/file.m', @group) @project.add_file_reference('relative/path/to/file.m', @group)
end.message.should.match /Paths must be absolute/ end.message.should.match /Paths must be absolute/
...@@ -187,27 +187,27 @@ module Pod ...@@ -187,27 +187,27 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#reference_for_path" do describe '#reference_for_path' do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false) @project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + "file.m" @file = config.sandbox.pod_dir('BananaLib') + 'file.m'
@group = @project.group_for_spec('BananaLib') @group = @project.group_for_spec('BananaLib')
@project.add_file_reference(@file, @group) @project.add_file_reference(@file, @group)
end end
it "returns the reference for the given path" do it 'returns the reference for the given path' do
ref = @project.reference_for_path(@file) ref = @project.reference_for_path(@file)
ref.hierarchy_path.should == '/Pods/BananaLib/file.m' ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end end
it "returns nil if no reference for the given path is available" do it 'returns nil if no reference for the given path is available' do
another_file = config.sandbox.pod_dir('BananaLib') + "another_file.m" another_file = config.sandbox.pod_dir('BananaLib') + 'another_file.m'
ref = @project.reference_for_path(another_file) ref = @project.reference_for_path(another_file)
ref.should.be.nil ref.should.be.nil
end end
it "raises if the given path is not absolute" do it 'raises if the given path is not absolute' do
should.raise ArgumentError do should.raise ArgumentError do
@project.reference_for_path('relative/path/to/file.m') @project.reference_for_path('relative/path/to/file.m')
end.message.should.match /Paths must be absolute/ end.message.should.match /Paths must be absolute/
...@@ -217,7 +217,7 @@ module Pod ...@@ -217,7 +217,7 @@ module Pod
#----------------------------------------# #----------------------------------------#
it "adds the Podfile configured as a Ruby file" do it 'adds the Podfile configured as a Ruby file' do
@project.add_podfile(config.sandbox.root + '../Podfile') @project.add_podfile(config.sandbox.root + '../Podfile')
f = @project['Podfile'] f = @project['Podfile']
f.source_tree.should == 'SOURCE_ROOT' f.source_tree.should == 'SOURCE_ROOT'
...@@ -227,8 +227,8 @@ module Pod ...@@ -227,8 +227,8 @@ module Pod
#----------------------------------------# #----------------------------------------#
describe "#add_build_configuration" do describe '#add_build_configuration' do
it "adds a preprocessor definition for build configurations" do it 'adds a preprocessor definition for build configurations' do
configuration = @project.add_build_configuration('Release', :release) configuration = @project.add_build_configuration('Release', :release)
settings = configuration.build_settings settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should.include('RELEASE=1') settings['GCC_PREPROCESSOR_DEFINITIONS'].should.include('RELEASE=1')
...@@ -238,21 +238,20 @@ module Pod ...@@ -238,21 +238,20 @@ module Pod
original = @project.build_configuration_list['Debug'] original = @project.build_configuration_list['Debug']
original_settings = original.build_settings original_settings = original.build_settings
original_settings['GCC_PREPROCESSOR_DEFINITIONS'].should == original_settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["DEBUG=1", "$(inherited)"] ['DEBUG=1', '$(inherited)']
configuration = @project.add_build_configuration('Debug', :debug) configuration = @project.add_build_configuration('Debug', :debug)
settings = configuration.build_settings settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should == settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["DEBUG=1", "$(inherited)"] ['DEBUG=1', '$(inherited)']
end end
it 'normalizes the name of the configuration' do
it "normalizes the name of the configuration" do
configuration = @project.add_build_configuration( configuration = @project.add_build_configuration(
'My Awesome Configuration', :release) 'My Awesome Configuration', :release)
settings = configuration.build_settings settings = configuration.build_settings
settings['GCC_PREPROCESSOR_DEFINITIONS'].should == settings['GCC_PREPROCESSOR_DEFINITIONS'].should ==
["MY_AWESOME_CONFIGURATION=1"] ['MY_AWESOME_CONFIGURATION=1']
end end
end end
end end
...@@ -261,6 +260,3 @@ module Pod ...@@ -261,6 +260,3 @@ module Pod
end end
end end
...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Resolver do describe Resolver do
describe "In general" do describe 'In general' do
before do before do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios
...@@ -12,48 +12,48 @@ module Pod ...@@ -12,48 +12,48 @@ module Pod
@resolver = Resolver.new(config.sandbox, @podfile, locked_deps) @resolver = Resolver.new(config.sandbox, @podfile, locked_deps)
end end
it "returns the sandbox" do it 'returns the sandbox' do
@resolver.sandbox.should == config.sandbox @resolver.sandbox.should == config.sandbox
end end
it "returns the podfile" do it 'returns the podfile' do
@resolver.podfile.should == @podfile @resolver.podfile.should == @podfile
end end
it "returns the locked dependencies" do it 'returns the locked dependencies' do
@resolver.locked_dependencies.should == [Dependency.new('BlocksKit', '1.5.2')] @resolver.locked_dependencies.should == [Dependency.new('BlocksKit', '1.5.2')]
end end
#--------------------------------------# #--------------------------------------#
it "resolves the specification of the podfile" do it 'resolves the specification of the podfile' do
target_definition = @podfile.target_definitions['Pods'] target_definition = @podfile.target_definitions['Pods']
specs = @resolver.resolve[target_definition] specs = @resolver.resolve[target_definition]
specs.map(&:to_s).should == [ specs.map(&:to_s).should == [
"A2DynamicDelegate (2.0.2)", 'A2DynamicDelegate (2.0.2)',
"BlocksKit (1.5.2)", 'BlocksKit (1.5.2)',
"libffi (3.0.13)" 'libffi (3.0.13)',
] ]
end end
it "returns the resolved specifications grouped by target definition" do it 'returns the resolved specifications grouped by target definition' do
@resolver.resolve @resolver.resolve
target_definition = @podfile.target_definitions['Pods'] target_definition = @podfile.target_definitions['Pods']
specs = @resolver.specs_by_target[target_definition] specs = @resolver.specs_by_target[target_definition]
specs.map(&:to_s).should == [ specs.map(&:to_s).should == [
"A2DynamicDelegate (2.0.2)", 'A2DynamicDelegate (2.0.2)',
"BlocksKit (1.5.2)", 'BlocksKit (1.5.2)',
"libffi (3.0.13)" 'libffi (3.0.13)',
] ]
end end
it "it resolves specifications from external sources" do it 'it resolves specifications from external sources' do
podspec = fixture('integration/Reachability/Reachability.podspec') podspec = fixture('integration/Reachability/Reachability.podspec')
spec = Specification.from_file(podspec) spec = Specification.from_file(podspec)
config.sandbox.expects(:specification).with('Reachability').returns(spec) config.sandbox.expects(:specification).with('Reachability').returns(spec)
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod "Reachability", :podspec => podspec pod 'Reachability', :podspec => podspec
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(config.sandbox, podfile)
resolver.resolve resolver.resolve
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Resolution" do describe 'Resolution' do
before do before do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
...@@ -73,7 +73,7 @@ module Pod ...@@ -73,7 +73,7 @@ module Pod
@resolver = Resolver.new(config.sandbox, @podfile) @resolver = Resolver.new(config.sandbox, @podfile)
end end
it "cross resolves dependencies" do it 'cross resolves dependencies' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '< 0.9.2' # 0.9.1 exits pod 'AFNetworking', '< 0.9.2' # 0.9.1 exits
...@@ -82,58 +82,58 @@ module Pod ...@@ -82,58 +82,58 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should == ["AFNetworking (0.9.1)", "AFQuickLookView (0.1.0)"] specs.should == ['AFNetworking (0.9.1)', 'AFQuickLookView (0.1.0)']
end end
it "holds the context state, such as cached specification sets" do it 'holds the context state, such as cached specification sets' do
@resolver.resolve @resolver.resolve
cached_sets = @resolver.send(:cached_sets) cached_sets = @resolver.send(:cached_sets)
cached_sets.values.sort_by(&:name).should == [ cached_sets.values.sort_by(&:name).should == [
SourcesManager.search_by_name('A2DynamicDelegate').first, SourcesManager.search_by_name('A2DynamicDelegate').first,
SourcesManager.search_by_name('BlocksKit').first, SourcesManager.search_by_name('BlocksKit').first,
SourcesManager.search_by_name('libffi').first SourcesManager.search_by_name('libffi').first,
].sort_by(&:name) ].sort_by(&:name)
end end
it "raises once any of the dependencies does not match the platform of its podfile target" do it 'raises once any of the dependencies does not match the platform of its podfile target' do
Specification.any_instance.stubs(:available_platforms).returns([Platform.new(:ios, '999')]) Specification.any_instance.stubs(:available_platforms).returns([Platform.new(:ios, '999')])
e = lambda { @resolver.resolve }.should.raise Informative e = lambda { @resolver.resolve }.should.raise Informative
e.message.should.match(/platform .* not compatible/) e.message.should.match(/platform .* not compatible/)
end end
it "does not raise if all dependencies are supported by the platform of the target definition" do it 'does not raise if all dependencies are supported by the platform of the target definition' do
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
end end
it "includes all the subspecs of a specification node" do it 'includes all the subspecs of a specification node' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '7.0' platform :ios, '7.0'
pod 'RestKit', '0.10.3' pod 'RestKit', '0.10.3'
end end
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
resolver.resolve.values.flatten.map(&:name).sort.should == %w{ resolver.resolve.values.flatten.map(&:name).sort.should == %w(
FileMD5Hash FileMD5Hash
ISO8601DateFormatter ISO8601DateFormatter
JSONKit JSONKit
LibComponentLogging-Core LibComponentLogging-Core
LibComponentLogging-NSLog LibComponentLogging-NSLog
NSData+Base64 NSData+Base64
RestKit RestKit
RestKit/JSON RestKit/JSON
RestKit/Network RestKit/Network
RestKit/ObjectMapping RestKit/ObjectMapping
RestKit/ObjectMapping/Core RestKit/ObjectMapping/Core
RestKit/ObjectMapping/CoreData RestKit/ObjectMapping/CoreData
RestKit/ObjectMapping/JSON RestKit/ObjectMapping/JSON
RestKit/ObjectMapping/XML RestKit/ObjectMapping/XML
RestKit/UI RestKit/UI
SOCKit SOCKit
XMLReader XMLReader
cocoa-oauth cocoa-oauth
} )
end end
it "handles correctly subspecs from external sources" do it 'handles correctly subspecs from external sources' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios platform :ios
pod 'MainSpec/FirstSubSpec', :git => 'GIT-URL' pod 'MainSpec/FirstSubSpec', :git => 'GIT-URL'
...@@ -151,7 +151,7 @@ module Pod ...@@ -151,7 +151,7 @@ module Pod
config.sandbox.expects(:specification).with('MainSpec').returns(spec) config.sandbox.expects(:specification).with('MainSpec').returns(spec)
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:name).sort specs = resolver.resolve.values.flatten.map(&:name).sort
specs.should == %w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec } specs.should == %w( MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec )
end end
it "marks a specification's version to be a HEAD version" do it "marks a specification's version to be a HEAD version" do
...@@ -168,27 +168,27 @@ module Pod ...@@ -168,27 +168,27 @@ module Pod
config.sandbox.head_pod?('JSONKit').should.be.true config.sandbox.head_pod?('JSONKit').should.be.true
end end
it "raises if it finds two conflicting dependencies" do it 'raises if it finds two conflicting dependencies' do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod 'JSONKit', "1.4" pod 'JSONKit', '1.4'
pod 'JSONKit', "1.5pre" pod 'JSONKit', '1.5pre'
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(config.sandbox, podfile)
e = lambda {resolver.resolve}.should.raise Pod::Informative e = lambda { resolver.resolve }.should.raise Pod::Informative
e.message.should.match(/Unable to satisfy the following requirements/) e.message.should.match(/Unable to satisfy the following requirements/)
end end
it "takes into account locked dependencies" do it 'takes into account locked dependencies' do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod 'JSONKit', "<= 1.5pre" pod 'JSONKit', '<= 1.5pre'
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(config.sandbox, podfile)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should == '1.5pre' version.to_s.should == '1.5pre'
locked_deps = [Dependency.new('JSONKit', "= 1.4")] locked_deps = [Dependency.new('JSONKit', '= 1.4')]
resolver = Resolver.new(config.sandbox, podfile, locked_deps) resolver = Resolver.new(config.sandbox, podfile, locked_deps)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should == '1.4' version.to_s.should == '1.4'
...@@ -197,9 +197,9 @@ module Pod ...@@ -197,9 +197,9 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Pre-release versions" do describe 'Pre-release versions' do
it "resolves explicitly requested pre-release versions" do it 'resolves explicitly requested pre-release versions' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '1.0RC3' pod 'AFNetworking', '1.0RC3'
...@@ -207,10 +207,10 @@ module Pod ...@@ -207,10 +207,10 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should == ["AFNetworking (1.0RC3)"] specs.should == ['AFNetworking (1.0RC3)']
end end
xit "resolves to latest minor version even when explicitly requesting pre-release versions when using ~>" do xit 'resolves to latest minor version even when explicitly requesting pre-release versions when using ~>' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '~> 1.0RC3' pod 'AFNetworking', '~> 1.0RC3'
...@@ -218,11 +218,11 @@ module Pod ...@@ -218,11 +218,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.2.0)"] specs.should == ['AFNetworking (1.2.0)']
end end
it "does not resolve to a pre-release version implicitly when matching exact version" do it 'does not resolve to a pre-release version implicitly when matching exact version' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '1.0' pod 'AFNetworking', '1.0'
...@@ -230,11 +230,11 @@ module Pod ...@@ -230,11 +230,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.0)"] specs.should == ['AFNetworking (1.0)']
end end
xit "does not resolve to a pre-release version implicitly when using <" do xit 'does not resolve to a pre-release version implicitly when using <' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '< 1.0' pod 'AFNetworking', '< 1.0'
...@@ -242,11 +242,11 @@ module Pod ...@@ -242,11 +242,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (0.10.1)"] specs.should == ['AFNetworking (0.10.1)']
end end
it "does not resolve to a pre-release version implicitly when using <=" do it 'does not resolve to a pre-release version implicitly when using <=' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '<= 1.0' pod 'AFNetworking', '<= 1.0'
...@@ -254,11 +254,11 @@ module Pod ...@@ -254,11 +254,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.0)"] specs.should == ['AFNetworking (1.0)']
end end
it "does not resolve to a pre-release version implicitly when using >" do it 'does not resolve to a pre-release version implicitly when using >' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '> 1.0', '< 1.3' pod 'AFNetworking', '> 1.0', '< 1.3'
...@@ -266,11 +266,11 @@ module Pod ...@@ -266,11 +266,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.2.1)"] specs.should == ['AFNetworking (1.2.1)']
end end
it "does not resolve to a pre-release version implicitly when using >=" do it 'does not resolve to a pre-release version implicitly when using >=' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '>= 1.0', '< 1.3' pod 'AFNetworking', '>= 1.0', '< 1.3'
...@@ -278,11 +278,11 @@ module Pod ...@@ -278,11 +278,11 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.2.1)"] specs.should == ['AFNetworking (1.2.1)']
end end
it "does not resolve to a pre-release version implicitly when using ~>" do it 'does not resolve to a pre-release version implicitly when using ~>' do
@podfile = Podfile.new do @podfile = Podfile.new do
platform :ios, '6.0' platform :ios, '6.0'
pod 'AFNetworking', '~> 1.0', '< 1.3' pod 'AFNetworking', '~> 1.0', '< 1.3'
...@@ -290,8 +290,8 @@ module Pod ...@@ -290,8 +290,8 @@ module Pod
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(config.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should != ["AFNetworking (1.0RC3)"] specs.should != ['AFNetworking (1.0RC3)']
specs.should == ["AFNetworking (1.2.1)"] specs.should == ['AFNetworking (1.2.1)']
end end
end end
end end
......
...@@ -11,14 +11,14 @@ module Pod ...@@ -11,14 +11,14 @@ module Pod
@accessor = FileAccessor.new(@path_list, @spec_consumer) @accessor = FileAccessor.new(@path_list, @spec_consumer)
end end
describe "In general" do describe 'In general' do
it "raises if the consumer is nil" do it 'raises if the consumer is nil' do
e = lambda { FileAccessor.new(@path_list, nil) }.should.raise Informative e = lambda { FileAccessor.new(@path_list, nil) }.should.raise Informative
e.message.should.match /without a specification consumer/ e.message.should.match /without a specification consumer/
end end
it "raises if the root does not exits" do it 'raises if the root does not exits' do
root = temporary_directory + 'missing_folder' root = temporary_directory + 'missing_folder'
path_list = Sandbox::PathList.new(root) path_list = Sandbox::PathList.new(root)
file_accessor = FileAccessor.new(path_list, @spec_consumer) file_accessor = FileAccessor.new(path_list, @spec_consumer)
...@@ -26,15 +26,15 @@ module Pod ...@@ -26,15 +26,15 @@ module Pod
e.message.should.match /non existent folder/ e.message.should.match /non existent folder/
end end
it "returns the root" do it 'returns the root' do
@accessor.root.should == @path_list.root @accessor.root.should == @path_list.root
end end
it "returns the specification" do it 'returns the specification' do
@accessor.spec.should == @spec @accessor.spec.should == @spec
end end
it "returns the platform for which the spec is being consumed" do it 'returns the platform for which the spec is being consumed' do
@accessor.platform_name.should == :ios @accessor.platform_name.should == :ios
end end
...@@ -42,114 +42,114 @@ module Pod ...@@ -42,114 +42,114 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Returning files" do describe 'Returning files' do
it "returns the source files" do it 'returns the source files' do
@accessor.source_files.sort.should == [ @accessor.source_files.sort.should == [
@root + "Classes/Banana.h", @root + 'Classes/Banana.h',
@root + "Classes/Banana.m", @root + 'Classes/Banana.m',
@root + "Classes/BananaPrivate.h", @root + 'Classes/BananaPrivate.h',
@root + "Classes/BananaTrace.d" @root + 'Classes/BananaTrace.d',
] ]
end end
it "returns the header files" do it 'returns the header files' do
@accessor.headers.sort.should == [ @accessor.headers.sort.should == [
@root + "Classes/Banana.h", @root + 'Classes/Banana.h',
@root + "Classes/BananaPrivate.h" @root + 'Classes/BananaPrivate.h',
] ]
end end
it "returns the public headers" do it 'returns the public headers' do
@accessor.public_headers.sort.should == [ @accessor.public_headers.sort.should == [
@root + "Classes/Banana.h" @root + 'Classes/Banana.h',
] ]
end end
it "returns all the headers if no public headers are defined" do it 'returns all the headers if no public headers are defined' do
@spec_consumer.stubs(:public_header_files).returns([]) @spec_consumer.stubs(:public_header_files).returns([])
@accessor.public_headers.sort.should == [ @accessor.public_headers.sort.should == [
@root + "Classes/Banana.h", @root + 'Classes/Banana.h',
@root + "Classes/BananaPrivate.h" @root + 'Classes/BananaPrivate.h',
] ]
end end
it "filters the private headers form the public headers" do it 'filters the private headers form the public headers' do
@spec_consumer.stubs(:public_header_files).returns([]) @spec_consumer.stubs(:public_header_files).returns([])
@spec_consumer.stubs(:private_header_files).returns(['**/*Private*']) @spec_consumer.stubs(:private_header_files).returns(['**/*Private*'])
@accessor.public_headers.sort.should == [ @accessor.public_headers.sort.should == [
@root + "Classes/Banana.h", @root + 'Classes/Banana.h',
] ]
end end
it "returns the resources" do it 'returns the resources' do
@accessor.resources.sort.should == [ @accessor.resources.sort.should == [
@root + "Resources/logo-sidebar.png", @root + 'Resources/logo-sidebar.png',
@root + "Resources/sub_dir", @root + 'Resources/sub_dir',
] ]
end end
it "includes folders in the resources" do it 'includes folders in the resources' do
@accessor.resources.should.include?(@root + "Resources/sub_dir") @accessor.resources.should.include?(@root + 'Resources/sub_dir')
end end
it "returns the preserve paths" do it 'returns the preserve paths' do
@accessor.preserve_paths.sort.should == [ @accessor.preserve_paths.sort.should == [
@root + "preserve_me.txt" @root + 'preserve_me.txt',
] ]
end end
it "includes folders in the preserve paths" do it 'includes folders in the preserve paths' do
@spec_consumer.stubs(:preserve_paths).returns(["Resources"]) @spec_consumer.stubs(:preserve_paths).returns(['Resources'])
@accessor.preserve_paths.should.include?(@root + "Resources") @accessor.preserve_paths.should.include?(@root + 'Resources')
end end
it "returns the paths of the framework bundles" do it 'returns the paths of the framework bundles' do
@accessor.vendored_frameworks.should.include?(@root + "Bananalib.framework") @accessor.vendored_frameworks.should.include?(@root + 'Bananalib.framework')
end end
it "returns the paths of the library files" do it 'returns the paths of the library files' do
@accessor.vendored_libraries.should.include?(@root + "libBananalib.a") @accessor.vendored_libraries.should.include?(@root + 'libBananalib.a')
end end
it "returns the resource bundles of the pod" do it 'returns the resource bundles of the pod' do
@spec_consumer.stubs(:resource_bundles).returns({"BananaLib" => "Resources/*"}) @spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [ resource_paths = [
@root + "Resources/logo-sidebar.png", @root + 'Resources/logo-sidebar.png',
@root + "Resources/sub_dir", @root + 'Resources/sub_dir',
] ]
@accessor.resource_bundles.should == { "BananaLib" => resource_paths } @accessor.resource_bundles.should == { 'BananaLib' => resource_paths }
end end
it "returns the paths of the files of the resource bundles" do it 'returns the paths of the files of the resource bundles' do
@spec_consumer.stubs(:resource_bundles).returns({"BananaLib" => "Resources/*"}) @spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [ resource_paths = [
@root + "Resources/logo-sidebar.png", @root + 'Resources/logo-sidebar.png',
@root + "Resources/sub_dir", @root + 'Resources/sub_dir',
] ]
@accessor.resource_bundle_files.should == resource_paths @accessor.resource_bundle_files.should == resource_paths
end end
it "returns the prefix header of the specification" do it 'returns the prefix header of the specification' do
@accessor.prefix_header.should == @root + 'Classes/BananaLib.pch' @accessor.prefix_header.should == @root + 'Classes/BananaLib.pch'
end end
it "returns the README file of the specification" do it 'returns the README file of the specification' do
@accessor.readme.should == @root + 'README' @accessor.readme.should == @root + 'README'
end end
it "returns the license file of the specification" do it 'returns the license file of the specification' do
@accessor.license.should == @root + 'LICENSE' @accessor.license.should == @root + 'LICENSE'
end end
#--------------------------------------# #--------------------------------------#
it "respects the exclude files" do it 'respects the exclude files' do
@spec_consumer.stubs(:exclude_files).returns(["Classes/BananaPrivate.h"]) @spec_consumer.stubs(:exclude_files).returns(['Classes/BananaPrivate.h'])
@accessor.source_files.sort.should == [ @accessor.source_files.sort.should == [
@root + "Classes/Banana.h", @root + 'Classes/Banana.h',
@root + "Classes/Banana.m", @root + 'Classes/Banana.m',
@root + "Classes/BananaTrace.d" @root + 'Classes/BananaTrace.d',
] ]
end end
...@@ -157,15 +157,15 @@ module Pod ...@@ -157,15 +157,15 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private helpers" do describe 'Private helpers' do
describe "#paths_for_attribute" do describe '#paths_for_attribute' do
it "takes into account dir patterns and excluded files" do it 'takes into account dir patterns and excluded files' do
file_patterns = ["Classes/*.{h,m,d}", "Vendor"] file_patterns = ['Classes/*.{h,m,d}', 'Vendor']
options = { options = {
:exclude_patterns => ["Classes/**/osx/**/*", "Resources/**/osx/**/*"], :exclude_patterns => ['Classes/**/osx/**/*', 'Resources/**/osx/**/*'],
:dir_pattern => "*.{h,hpp,hh,m,mm,c,cpp}", :dir_pattern => '*.{h,hpp,hh,m,mm,c,cpp}',
:include_dirs => false, :include_dirs => false,
} }
@spec.exclude_files = options[:exclude_patterns] @spec.exclude_files = options[:exclude_patterns]
......
...@@ -13,38 +13,38 @@ module Pod ...@@ -13,38 +13,38 @@ module Pod
end end
it "can add namespaced headers to it's header path using symlinks and return the relative path" do it "can add namespaced headers to it's header path using symlinks and return the relative path" do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/") FileUtils.mkdir_p(@sandbox.root + 'ExampleLib/')
namespace_path = Pathname.new("ExampleLib") namespace_path = Pathname.new('ExampleLib')
relative_header_paths = [ relative_header_paths = [
Pathname.new("ExampleLib/MyHeader.h"), Pathname.new('ExampleLib/MyHeader.h'),
Pathname.new("ExampleLib/MyOtherHeader.h") Pathname.new('ExampleLib/MyOtherHeader.h'),
] ]
relative_header_paths.each do |path| relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') } File.open(@sandbox.root + path, 'w') { |file| file.write('hello') }
end end
symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths) symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths)
symlink_paths.each do |path| symlink_paths.each do |path|
path.should.be.symlink path.should.be.symlink
File.read(path).should == "hello" File.read(path).should == 'hello'
end end
end end
it 'keeps a list of unique header search paths when headers are added' do it 'keeps a list of unique header search paths when headers are added' do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Dir") FileUtils.mkdir_p(@sandbox.root + 'ExampleLib/Dir')
namespace_path = Pathname.new("ExampleLib") namespace_path = Pathname.new('ExampleLib')
relative_header_paths = [ relative_header_paths = [
Pathname.new("ExampleLib/Dir/MyHeader.h"), Pathname.new('ExampleLib/Dir/MyHeader.h'),
Pathname.new("ExampleLib/Dir/MyOtherHeader.h") Pathname.new('ExampleLib/Dir/MyOtherHeader.h'),
] ]
relative_header_paths.each do |path| relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') } File.open(@sandbox.root + path, 'w') { |file| file.write('hello') }
end end
@header_dir.add_files(namespace_path, relative_header_paths) @header_dir.add_files(namespace_path, relative_header_paths)
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib") @header_dir.search_paths.should.include('${PODS_ROOT}/Headers/ExampleLib')
end end
it 'always adds the Headers root to the header search paths' do it 'always adds the Headers root to the header search paths' do
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers") @header_dir.search_paths.should.include('${PODS_ROOT}/Headers')
end end
end end
end end
...@@ -7,14 +7,14 @@ module Pod ...@@ -7,14 +7,14 @@ module Pod
@path_list = Sandbox::PathList.new(fixture('banana-lib')) @path_list = Sandbox::PathList.new(fixture('banana-lib'))
end end
describe "In general" do describe 'In general' do
it "creates the list of all the files" do it 'creates the list of all the files' do
files = @path_list.files files = @path_list.files
files.reject! do |f| files.reject! do |f|
f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store') f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store')
end end
expected = %w[ expected = %w(
BananaLib.podspec BananaLib.podspec
Classes/Banana.h Classes/Banana.h
Classes/Banana.m Classes/Banana.m
...@@ -27,109 +27,109 @@ module Pod ...@@ -27,109 +27,109 @@ module Pod
libBananalib.a libBananalib.a
preserve_me.txt preserve_me.txt
sub-dir/sub-dir-2/somefile.txt sub-dir/sub-dir-2/somefile.txt
] )
files.sort.should == expected files.sort.should == expected
end end
it "creates the list of the directories" do it 'creates the list of the directories' do
dirs = @path_list.dirs dirs = @path_list.dirs
dirs.reject! do |f| dirs.reject! do |f|
f.include?('libPusher') || f.include?('.git') f.include?('libPusher') || f.include?('.git')
end end
dirs.sort.should == %w| Bananalib.framework Classes Resources Resources/sub_dir sub-dir sub-dir/sub-dir-2 | dirs.sort.should == %w( Bananalib.framework Classes Resources Resources/sub_dir sub-dir sub-dir/sub-dir-2 )
end end
it "handles directories with glob metacharacters" do it 'handles directories with glob metacharacters' do
root = temporary_directory + '[CP] Test' root = temporary_directory + '[CP] Test'
root.mkpath root.mkpath
FileUtils.touch(root + 'Class.h') FileUtils.touch(root + 'Class.h')
@path_list = Sandbox::PathList.new(root) @path_list = Sandbox::PathList.new(root)
@path_list.files.should == ["Class.h"] @path_list.files.should == ['Class.h']
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Globbing" do describe 'Globbing' do
it "can glob the root for a given pattern" do it 'can glob the root for a given pattern' do
paths = @path_list.relative_glob('Classes/*.{h,m}').map(&:to_s) paths = @path_list.relative_glob('Classes/*.{h,m}').map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Classes/Banana.h Classes/Banana.h
Classes/Banana.m Classes/Banana.m
Classes/BananaPrivate.h Classes/BananaPrivate.h
] )
end end
it "can return the absolute paths from glob" do it 'can return the absolute paths from glob' do
paths = @path_list.glob('Classes/*.{h,m}') paths = @path_list.glob('Classes/*.{h,m}')
paths.all? { |p| p.absolute? }.should == true paths.all? { |p| p.absolute? }.should == true
end end
it "can return the relative paths from glob" do it 'can return the relative paths from glob' do
paths = @path_list.relative_glob('Classes/*.{h,m}') paths = @path_list.relative_glob('Classes/*.{h,m}')
paths.any? { |p| p.absolute? }.should == false paths.any? { |p| p.absolute? }.should == false
end end
it "supports the `**` glob pattern" do it 'supports the `**` glob pattern' do
paths = @path_list.relative_glob('Classes/**/*.{h,m}').map(&:to_s) paths = @path_list.relative_glob('Classes/**/*.{h,m}').map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Classes/Banana.h Classes/Banana.h
Classes/Banana.m Classes/Banana.m
Classes/BananaPrivate.h Classes/BananaPrivate.h
] )
end end
it "supports an optional pattern for globbing directories" do it 'supports an optional pattern for globbing directories' do
paths = @path_list.relative_glob('Classes', { :dir_pattern => '*.{h,m}'} ).map(&:to_s) paths = @path_list.relative_glob('Classes', :dir_pattern => '*.{h,m}').map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Classes/Banana.h Classes/Banana.h
Classes/Banana.m Classes/Banana.m
Classes/BananaPrivate.h Classes/BananaPrivate.h
] )
end end
it "handles directories specified with a trailing slash" do it 'handles directories specified with a trailing slash' do
paths = @path_list.relative_glob('Classes/', { :dir_pattern => '*.{h,m}'} ).map(&:to_s) paths = @path_list.relative_glob('Classes/', :dir_pattern => '*.{h,m}').map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Classes/Banana.h Classes/Banana.h
Classes/Banana.m Classes/Banana.m
Classes/BananaPrivate.h Classes/BananaPrivate.h
] )
end end
it "supports an optional list of patterns to exclude" do it 'supports an optional list of patterns to exclude' do
exclude_patterns = ['**/*.m', '**/*Private*.*'] exclude_patterns = ['**/*.m', '**/*Private*.*']
paths = @path_list.relative_glob('Classes/*', { :exclude_patterns => exclude_patterns }).map(&:to_s) paths = @path_list.relative_glob('Classes/*', :exclude_patterns => exclude_patterns).map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Classes/Banana.h Classes/Banana.h
Classes/BananaLib.pch Classes/BananaLib.pch
Classes/BananaTrace.d Classes/BananaTrace.d
] )
end end
it "allows to specify folders in the exclude patterns" do it 'allows to specify folders in the exclude patterns' do
paths = @path_list.relative_glob('Classes/*', { :exclude_patterns => 'Classes' }).map(&:to_s) paths = @path_list.relative_glob('Classes/*', :exclude_patterns => 'Classes').map(&:to_s)
paths.sort.should.be.empty paths.sort.should.be.empty
end end
it "can optionally include the directories in the results" do it 'can optionally include the directories in the results' do
paths = @path_list.relative_glob('Resources/*', { :include_dirs => true }).map(&:to_s) paths = @path_list.relative_glob('Resources/*', :include_dirs => true).map(&:to_s)
paths.sort.should == %w[ paths.sort.should == %w(
Resources/logo-sidebar.png Resources/logo-sidebar.png
Resources/sub_dir Resources/sub_dir
] )
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Private Helpers" do describe 'Private Helpers' do
describe "#directory?" do describe '#directory?' do
it "detects a directory" do it 'detects a directory' do
@path_list.send(:directory?, 'classes').should == true @path_list.send(:directory?, 'classes').should == true
end end
...@@ -140,39 +140,39 @@ module Pod ...@@ -140,39 +140,39 @@ module Pod
#--------------------------------------# #--------------------------------------#
describe "#directory?" do describe '#directory?' do
it "expands a pattern into all the combinations of Dir#glob literals" do it 'expands a pattern into all the combinations of Dir#glob literals' do
patterns = @path_list.send(:dir_glob_equivalent_patterns, '{file1,file2}.{h,m}') patterns = @path_list.send(:dir_glob_equivalent_patterns, '{file1,file2}.{h,m}')
patterns.sort.should == %w[ file1.h file1.m file2.h file2.m ] patterns.sort.should == %w( file1.h file1.m file2.h file2.m )
end end
it "returns the original pattern if there are no Dir#glob expansions" do it 'returns the original pattern if there are no Dir#glob expansions' do
patterns = @path_list.send(:dir_glob_equivalent_patterns, 'file*.*') patterns = @path_list.send(:dir_glob_equivalent_patterns, 'file*.*')
patterns.sort.should == %w[ file*.* ] patterns.sort.should == %w( file*.* )
end end
it "expands `**`" do it 'expands `**`' do
patterns = @path_list.send(:dir_glob_equivalent_patterns, 'Classes/**/file.m') patterns = @path_list.send(:dir_glob_equivalent_patterns, 'Classes/**/file.m')
patterns.sort.should == %w[ Classes/**/file.m Classes/file.m ] patterns.sort.should == %w( Classes/**/file.m Classes/file.m )
end end
it "supports a combination of `**` and literals" do it 'supports a combination of `**` and literals' do
patterns = @path_list.send(:dir_glob_equivalent_patterns, 'Classes/**/file.{h,m}') patterns = @path_list.send(:dir_glob_equivalent_patterns, 'Classes/**/file.{h,m}')
patterns.sort.should == %w[ patterns.sort.should == %w(
Classes/**/file.h Classes/**/file.h
Classes/**/file.m Classes/**/file.m
Classes/file.h Classes/file.h
Classes/file.m Classes/file.m
] )
end end
end end
#--------------------------------------# #--------------------------------------#
describe "#escape_path_for_glob" do describe '#escape_path_for_glob' do
it "escapes metacharacters" do it 'escapes metacharacters' do
escaped = @path_list.send(:escape_path_for_glob, '[]{}?**') escaped = @path_list.send(:escape_path_for_glob, '[]{}?**')
escaped.to_s.should == '\[\]\{\}\?\*\*' escaped.to_s.should == '\[\]\{\}\?\*\*'
end end
......
...@@ -9,9 +9,9 @@ module Pod ...@@ -9,9 +9,9 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "In general" do describe 'In general' do
it "reads the real path of the root so it can be used to build relative paths" do it 'reads the real path of the root so it can be used to build relative paths' do
root_realpath = temporary_directory + 'Folder/SubFolder' root_realpath = temporary_directory + 'Folder/SubFolder'
FileUtils.mkdir_p(root_realpath) FileUtils.mkdir_p(root_realpath)
symlink = temporary_directory + 'symlink' symlink = temporary_directory + 'symlink'
...@@ -24,24 +24,24 @@ module Pod ...@@ -24,24 +24,24 @@ module Pod
File.directory?(temporary_directory + 'Sandbox').should.be.true File.directory?(temporary_directory + 'Sandbox').should.be.true
end end
it "returns the manifest" do it 'returns the manifest' do
@sandbox.manifest.should == nil @sandbox.manifest.should.nil?
end end
it "returns the project" do it 'returns the project' do
@sandbox.project.should == nil @sandbox.project.should.nil?
end end
it "returns the public headers store" do it 'returns the public headers store' do
@sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers' @sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers'
end end
it "deletes the entire root directory on implode" do it 'deletes the entire root directory on implode' do
@sandbox.implode @sandbox.implode
File.directory?(temporary_directory + 'Sandbox').should.be.false File.directory?(temporary_directory + 'Sandbox').should.be.false
end end
it "cleans any trace of the Pod with the given name" do it 'cleans any trace of the Pod with the given name' do
pod_root = @sandbox.root + 'BananaLib' pod_root = @sandbox.root + 'BananaLib'
pod_root.mkpath pod_root.mkpath
@sandbox.store_podspec('BananaLib', fixture('banana-lib/BananaLib.podspec')) @sandbox.store_podspec('BananaLib', fixture('banana-lib/BananaLib.podspec'))
...@@ -63,51 +63,51 @@ module Pod ...@@ -63,51 +63,51 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Paths" do describe 'Paths' do
it "returns the path of the manifest" do it 'returns the path of the manifest' do
@sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock' @sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock'
end end
it "returns the path of the Pods project" do it 'returns the path of the Pods project' do
@sandbox.project_path.should == temporary_directory + 'Sandbox/Pods.xcodeproj' @sandbox.project_path.should == temporary_directory + 'Sandbox/Pods.xcodeproj'
end end
it "returns the directory for the support files of a library" do it 'returns the directory for the support files of a library' do
@sandbox.library_support_files_dir('Pods').should == temporary_directory + 'Sandbox' @sandbox.library_support_files_dir('Pods').should == temporary_directory + 'Sandbox'
end end
it "returns the directory where a Pod is stored" do it 'returns the directory where a Pod is stored' do
@sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit' @sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit'
end end
it "returns the directory where a local Pod is stored" do it 'returns the directory where a local Pod is stored' do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib', Pathname.new('Some Path'))
@sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path') @sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path')
end end
it "returns the directory where to store the documentation" do it 'returns the directory where to store the documentation' do
@sandbox.documentation_dir.should == temporary_directory + 'Sandbox/Documentation' @sandbox.documentation_dir.should == temporary_directory + 'Sandbox/Documentation'
end end
it "handles symlinks in /tmp" do it 'handles symlinks in /tmp' do
tmp_sandbox = Pod::Sandbox.new("/tmp/CocoaPods") tmp_sandbox = Pod::Sandbox.new('/tmp/CocoaPods')
tmp_sandbox.root.should.be == Pathname.new("/private/tmp/CocoaPods") tmp_sandbox.root.should.be == Pathname.new('/private/tmp/CocoaPods')
tmp_sandbox.implode tmp_sandbox.implode
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Specification store" do describe 'Specification store' do
it "loads the stored specification with the given name" do it 'loads the stored specification with the given name' do
(@sandbox.root + 'Local Podspecs').mkdir (@sandbox.root + 'Local Podspecs').mkdir
FileUtils.cp(fixture('banana-lib/BananaLib.podspec'), @sandbox.root + 'Local Podspecs') FileUtils.cp(fixture('banana-lib/BananaLib.podspec'), @sandbox.root + 'Local Podspecs')
@sandbox.specification('BananaLib').name.should == 'BananaLib' @sandbox.specification('BananaLib').name.should == 'BananaLib'
end end
it "loads the stored specification from the original path" do it 'loads the stored specification from the original path' do
spec_file = fixture('banana-lib/BananaLib.podspec') spec_file = fixture('banana-lib/BananaLib.podspec')
spec = Specification.from_file(spec_file) spec = Specification.from_file(spec_file)
Specification.expects(:from_file).with do Specification.expects(:from_file).with do
...@@ -119,7 +119,7 @@ module Pod ...@@ -119,7 +119,7 @@ module Pod
@sandbox.specification('BananaLib') @sandbox.specification('BananaLib')
end end
it "returns the directory where to store the specifications" do it 'returns the directory where to store the specifications' do
@sandbox.specifications_dir.should == temporary_directory + 'Sandbox/Local Podspecs' @sandbox.specifications_dir.should == temporary_directory + 'Sandbox/Local Podspecs'
end end
...@@ -129,14 +129,14 @@ module Pod ...@@ -129,14 +129,14 @@ module Pod
@sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec' @sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec'
end end
it "stores a podspec with a given path into the sandbox" do it 'stores a podspec with a given path into the sandbox' do
@sandbox.store_podspec('BananaLib', fixture('banana-lib/BananaLib.podspec')) @sandbox.store_podspec('BananaLib', fixture('banana-lib/BananaLib.podspec'))
path = @sandbox.root + 'Local Podspecs/BananaLib.podspec' path = @sandbox.root + 'Local Podspecs/BananaLib.podspec'
path.should.exist path.should.exist
@sandbox.specification_path('BananaLib').should == path @sandbox.specification_path('BananaLib').should == path
end end
it "stores a podspec with the given string into the sandbox" do it 'stores a podspec with the given string into the sandbox' do
podspec_string = fixture('banana-lib/BananaLib.podspec').read podspec_string = fixture('banana-lib/BananaLib.podspec').read
@sandbox.store_podspec('BananaLib', podspec_string) @sandbox.store_podspec('BananaLib', podspec_string)
path = @sandbox.root + 'Local Podspecs/BananaLib.podspec' path = @sandbox.root + 'Local Podspecs/BananaLib.podspec'
...@@ -148,14 +148,14 @@ module Pod ...@@ -148,14 +148,14 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Pods information" do describe 'Pods information' do
it "stores the list of the names of the pre-downloaded pods" do it 'stores the list of the names of the pre-downloaded pods' do
@sandbox.store_pre_downloaded_pod('BananaLib') @sandbox.store_pre_downloaded_pod('BananaLib')
@sandbox.predownloaded_pods.should == ['BananaLib'] @sandbox.predownloaded_pods.should == ['BananaLib']
end end
it "returns whether a Pod has been pre-downloaded" do it 'returns whether a Pod has been pre-downloaded' do
@sandbox.predownloaded_pods << 'BananaLib' @sandbox.predownloaded_pods << 'BananaLib'
@sandbox.predownloaded?('BananaLib').should.be.true @sandbox.predownloaded?('BananaLib').should.be.true
@sandbox.predownloaded?('BananaLib/Subspec').should.be.true @sandbox.predownloaded?('BananaLib/Subspec').should.be.true
...@@ -164,12 +164,12 @@ module Pod ...@@ -164,12 +164,12 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "stores the list of the names of the pre-downloaded pods" do it 'stores the list of the names of the pre-downloaded pods' do
@sandbox.store_head_pod('BananaLib') @sandbox.store_head_pod('BananaLib')
@sandbox.head_pods.should == ['BananaLib'] @sandbox.head_pods.should == ['BananaLib']
end end
it "returns whether a Pod has been pre-downloaded" do it 'returns whether a Pod has been pre-downloaded' do
@sandbox.head_pods << 'BananaLib' @sandbox.head_pods << 'BananaLib'
@sandbox.head_pod?('BananaLib').should.be.true @sandbox.head_pod?('BananaLib').should.be.true
@sandbox.head_pod?('BananaLib/Subspec').should.be.true @sandbox.head_pod?('BananaLib/Subspec').should.be.true
...@@ -178,36 +178,36 @@ module Pod ...@@ -178,36 +178,36 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "returns the checkout sources of the Pods" do it 'returns the checkout sources of the Pods' do
@sandbox.store_pre_downloaded_pod('BananaLib/Subspec') @sandbox.store_pre_downloaded_pod('BananaLib/Subspec')
@sandbox.predownloaded_pods.should == ['BananaLib'] @sandbox.predownloaded_pods.should == ['BananaLib']
end end
it "stores the checkout source of a Pod" do it 'stores the checkout source of a Pod' do
source = {:git => 'example.com', :commit => 'SHA'} source = { :git => 'example.com', :commit => 'SHA' }
@sandbox.store_checkout_source('BananaLib/Subspec', source ) @sandbox.store_checkout_source('BananaLib/Subspec', source)
@sandbox.checkout_sources['BananaLib'].should == source @sandbox.checkout_sources['BananaLib'].should == source
end end
it "returns the checkout sources of the Pods" do it 'returns the checkout sources of the Pods' do
source = {:git => 'example.com', :commit => 'SHA'} source = { :git => 'example.com', :commit => 'SHA' }
@sandbox.store_checkout_source('BananaLib', source ) @sandbox.store_checkout_source('BananaLib', source)
@sandbox.checkout_sources.should == { 'BananaLib' => source } @sandbox.checkout_sources.should == { 'BananaLib' => source }
end end
#--------------------------------------# #--------------------------------------#
it "stores the local path of a Pod" do it 'stores the local path of a Pod' do
@sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path'))
@sandbox.development_pods['BananaLib'].should == 'Some Path' @sandbox.development_pods['BananaLib'].should == 'Some Path'
end end
it "returns the path of the local pods grouped by name" do it 'returns the path of the local pods grouped by name' do
@sandbox.store_local_path('BananaLib', 'Some Path') @sandbox.store_local_path('BananaLib', 'Some Path')
@sandbox.development_pods.should == { 'BananaLib' => 'Some Path' } @sandbox.development_pods.should == { 'BananaLib' => 'Some Path' }
end end
it "returns whether a Pod is local" do it 'returns whether a Pod is local' do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib', Pathname.new('Some Path'))
@sandbox.local?('BananaLib').should.be.true @sandbox.local?('BananaLib').should.be.true
@sandbox.local?('BananaLib/Subspec').should.be.true @sandbox.local?('BananaLib/Subspec').should.be.true
......
...@@ -2,26 +2,26 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,26 +2,26 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe AggregateTarget do describe AggregateTarget do
describe "In general" do describe 'In general' do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox) @target = AggregateTarget.new(@target_definition, config.sandbox)
end end
it "returns the target_definition that generated it" do it 'returns the target_definition that generated it' do
@target.target_definition.should == @target_definition @target.target_definition.should == @target_definition
end end
it "returns the label of the target definition" do it 'returns the label of the target definition' do
@target.label.should == 'Pods' @target.label.should == 'Pods'
end end
it "returns its name" do it 'returns its name' do
@target.name.should == 'Pods' @target.name.should == 'Pods'
end end
it "returns the name of its product" do it 'returns the name of its product' do
@target.product_name.should == 'libPods.a' @target.product_name.should == 'libPods.a'
end end
...@@ -35,7 +35,7 @@ module Pod ...@@ -35,7 +35,7 @@ module Pod
end end
end end
describe "Support files" do describe 'Support files' do
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
...@@ -43,40 +43,40 @@ module Pod ...@@ -43,40 +43,40 @@ module Pod
@target.client_root = config.sandbox.root.dirname @target.client_root = config.sandbox.root.dirname
end end
it "returns the absolute path of the xcconfig file" do it 'returns the absolute path of the xcconfig file' do
@target.xcconfig_path("Release").to_s.should.include?('Pods/Pods.release.xcconfig') @target.xcconfig_path('Release').to_s.should.include?('Pods/Pods.release.xcconfig')
end end
it "returns the absolute path of the resources script" do it 'returns the absolute path of the resources script' do
@target.copy_resources_script_path.to_s.should.include?('Pods/Pods-resources.sh') @target.copy_resources_script_path.to_s.should.include?('Pods/Pods-resources.sh')
end end
it "returns the absolute path of the target header file" do it 'returns the absolute path of the target header file' do
@target.target_environment_header_path.to_s.should.include?('Pods/Pods-environment.h') @target.target_environment_header_path.to_s.should.include?('Pods/Pods-environment.h')
end end
it "returns the absolute path of the prefix header file" do it 'returns the absolute path of the prefix header file' do
@target.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch') @target.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch')
end end
it "returns the absolute path of the bridge support file" do it 'returns the absolute path of the bridge support file' do
@target.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport') @target.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport')
end end
it "returns the absolute path of the acknowledgements files without extension" do it 'returns the absolute path of the acknowledgements files without extension' do
@target.acknowledgements_basepath.to_s.should.include?('Pods/Pods-acknowledgements') @target.acknowledgements_basepath.to_s.should.include?('Pods/Pods-acknowledgements')
end end
it "returns the path of the resources script relative to the user project" do it 'returns the path of the resources script relative to the user project' do
@target.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh' @target.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh'
end end
it "returns the path of the xcconfig file relative to the user project" do it 'returns the path of the xcconfig file relative to the user project' do
@target.xcconfig_relative_path("Release").should == 'Pods/Pods.release.xcconfig' @target.xcconfig_relative_path('Release').should == 'Pods/Pods.release.xcconfig'
end end
end end
describe "Pod targets" do describe 'Pod targets' do
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
...@@ -86,33 +86,33 @@ module Pod ...@@ -86,33 +86,33 @@ module Pod
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
end end
it "returns pod targets by build configuration" do it 'returns pod targets by build configuration' do
pod_target_release = PodTarget.new([@spec], @target_definition, config.sandbox) pod_target_release = PodTarget.new([@spec], @target_definition, config.sandbox)
pod_target_release.expects(:include_in_build_config?).with("Debug").returns(false) pod_target_release.expects(:include_in_build_config?).with('Debug').returns(false)
pod_target_release.expects(:include_in_build_config?).with("Release").returns(true) pod_target_release.expects(:include_in_build_config?).with('Release').returns(true)
@target.pod_targets = [@pod_target, pod_target_release] @target.pod_targets = [@pod_target, pod_target_release]
@target.user_build_configurations = { @target.user_build_configurations = {
"Debug" => :debug, 'Debug' => :debug,
"Release" => :release 'Release' => :release,
} }
expected = { expected = {
"Debug" => @pod_target.specs, 'Debug' => @pod_target.specs,
"Release" => (@pod_target.specs + pod_target_release.specs) 'Release' => (@pod_target.specs + pod_target_release.specs),
} }
@target.specs_by_build_configuration.should == expected @target.specs_by_build_configuration.should == expected
end end
it "returns the specs of the Pods used by this aggregate target" do it 'returns the specs of the Pods used by this aggregate target' do
@target.specs.map(&:name).should == ["BananaLib"] @target.specs.map(&:name).should == ['BananaLib']
end end
it "returns the specs of the Pods used by this aggregate target" do it 'returns the specs of the Pods used by this aggregate target' do
@target.specs.map(&:name).should == ["BananaLib"] @target.specs.map(&:name).should == ['BananaLib']
end end
it "returns the spec consumers for the pod targets" do it 'returns the spec consumers for the pod targets' do
consumer_reps = @target.spec_consumers.map { |consumer| [consumer.spec.name, consumer.platform_name ] } consumer_reps = @target.spec_consumers.map { |consumer| [consumer.spec.name, consumer.platform_name] }
consumer_reps.should == [["BananaLib", :ios]] consumer_reps.should == [['BananaLib', :ios]]
end end
end end
end end
......
...@@ -9,48 +9,48 @@ module Pod ...@@ -9,48 +9,48 @@ module Pod
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
end end
describe "In general" do describe 'In general' do
it "returns the target_definition that generated it" do it 'returns the target_definition that generated it' do
@pod_target.target_definition.should == @target_definition @pod_target.target_definition.should == @target_definition
end end
it "returns its name" do it 'returns its name' do
@pod_target.name.should == 'Pods-BananaLib' @pod_target.name.should == 'Pods-BananaLib'
end end
it "returns the name of its product" do it 'returns the name of its product' do
@pod_target.product_name.should == 'libPods-BananaLib.a' @pod_target.product_name.should == 'libPods-BananaLib.a'
end end
it "returns the spec consumers for the pod targets" do it 'returns the spec consumers for the pod targets' do
@pod_target.spec_consumers.should.not == nil @pod_target.spec_consumers.should.not.nil?
end end
it "returns the root spec" do it 'returns the root spec' do
@pod_target.root_spec.name.should == 'BananaLib' @pod_target.root_spec.name.should == 'BananaLib'
end end
it "returns the name of the Pod" do it 'returns the name of the Pod' do
@pod_target.pod_name.should == 'BananaLib' @pod_target.pod_name.should == 'BananaLib'
end end
it "returns the name of the Pods on which this target depends" do it 'returns the name of the Pods on which this target depends' do
@pod_target.dependencies.should == ["monkey"] @pod_target.dependencies.should == ['monkey']
end end
it "returns whether it is whitelisted in a build configuration" do it 'returns whether it is whitelisted in a build configuration' do
@target_definition.store_pod('BananaLib') @target_definition.store_pod('BananaLib')
@target_definition.whitelist_pod_for_configuration('BananaLib', 'debug') @target_definition.whitelist_pod_for_configuration('BananaLib', 'debug')
@pod_target.include_in_build_config?('Debug').should.be.true @pod_target.include_in_build_config?('Debug').should.be.true
@pod_target.include_in_build_config?('Release').should.be.false @pod_target.include_in_build_config?('Release').should.be.false
end end
it "is whitelisted on all build configurations of it is a dependency of other Pods" do it 'is whitelisted on all build configurations of it is a dependency of other Pods' do
@pod_target.include_in_build_config?('Debug').should.be.true @pod_target.include_in_build_config?('Debug').should.be.true
@pod_target.include_in_build_config?('Release').should.be.true @pod_target.include_in_build_config?('Release').should.be.true
end end
it "raises if a Pod is whitelisted for different build configurations" do it 'raises if a Pod is whitelisted for different build configurations' do
@target_definition.store_pod('BananaLib') @target_definition.store_pod('BananaLib')
@target_definition.store_pod('BananaLib/Subspec') @target_definition.store_pod('BananaLib/Subspec')
@target_definition.whitelist_pod_for_configuration('BananaLib', 'debug') @target_definition.whitelist_pod_for_configuration('BananaLib', 'debug')
...@@ -60,24 +60,24 @@ module Pod ...@@ -60,24 +60,24 @@ module Pod
end end
end end
describe "Support files" do describe 'Support files' do
it "returns the absolute path of the xcconfig file" do it 'returns the absolute path of the xcconfig file' do
@pod_target.xcconfig_path("Release").to_s.should.include 'Pods/Pods-BananaLib.release.xcconfig' @pod_target.xcconfig_path('Release').to_s.should.include 'Pods/Pods-BananaLib.release.xcconfig'
end end
it "returns the absolute path of the target header file" do it 'returns the absolute path of the target header file' do
@pod_target.target_environment_header_path.to_s.should.include 'Pods/Pods-environment.h' @pod_target.target_environment_header_path.to_s.should.include 'Pods/Pods-environment.h'
end end
it "returns the absolute path of the prefix header file" do it 'returns the absolute path of the prefix header file' do
@pod_target.prefix_header_path.to_s.should.include 'Pods/Pods-BananaLib-prefix.pch' @pod_target.prefix_header_path.to_s.should.include 'Pods/Pods-BananaLib-prefix.pch'
end end
it "returns the absolute path of the bridge support file" do it 'returns the absolute path of the bridge support file' do
@pod_target.bridge_support_path.to_s.should.include 'Pods/Pods-BananaLib.bridgesupport' @pod_target.bridge_support_path.to_s.should.include 'Pods/Pods-BananaLib.bridgesupport'
end end
it "returns the absolute path of the public and private xcconfig files" do it 'returns the absolute path of the public and private xcconfig files' do
@pod_target.xcconfig_path.to_s.should.include 'Pods/Pods-BananaLib.xcconfig' @pod_target.xcconfig_path.to_s.should.include 'Pods/Pods-BananaLib.xcconfig'
@pod_target.xcconfig_private_path.to_s.should.include 'Pods/Pods-BananaLib-Private.xcconfig' @pod_target.xcconfig_private_path.to_s.should.include 'Pods/Pods-BananaLib-Private.xcconfig'
end end
......
...@@ -77,7 +77,7 @@ EOS ...@@ -77,7 +77,7 @@ EOS
EOS EOS
@report.stubs(:host_information).returns(':host_information') @report.stubs(:host_information).returns(':host_information')
@report.stubs(:xcode_information).returns(':xcode_information') @report.stubs(:xcode_information).returns(':xcode_information')
@report.stubs(:repo_information).returns(['repo_1', 'repo_2']) @report.stubs(:repo_information).returns(%w(repo_1 repo_2))
report = remove_color(@report.report(@exception)) report = remove_color(@report.report(@exception))
report.should == expected report.should == expected
end end
......
...@@ -6,7 +6,7 @@ module Bacon ...@@ -6,7 +6,7 @@ module Bacon
alias_method :after_webmock, :after alias_method :after_webmock, :after
def after(&block) def after(&block)
after_webmock do after_webmock do
block.call() block.call
WebMock.reset! WebMock.reset!
end end
end end
...@@ -24,7 +24,7 @@ module Pod ...@@ -24,7 +24,7 @@ module Pod
# #
def write_podspec(text, name = 'JSONKit.podspec.json') def write_podspec(text, name = 'JSONKit.podspec.json')
file = temporary_directory + name file = temporary_directory + name
File.open(file, 'w') {|f| f.write(text) } File.open(file, 'w') { |f| f.write(text) }
file file
end end
...@@ -45,8 +45,8 @@ module Pod ...@@ -45,8 +45,8 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Quick mode" do describe 'Quick mode' do
it "validates a correct podspec" do it 'validates a correct podspec' do
sut = Validator.new(podspec_path) sut = Validator.new(podspec_path)
sut.quick = true sut.quick = true
sut.validate sut.validate
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
sut.validated?.should.be.true sut.validated?.should.be.true
end end
it "lints the podspec during validation" do it 'lints the podspec during validation' do
podspec = stub_podspec(/.*name.*/, '"name": "TEST",') podspec = stub_podspec(/.*name.*/, '"name": "TEST",')
file = write_podspec(podspec) file = write_podspec(podspec)
sut = Validator.new(file) sut = Validator.new(file)
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
sut.validated?.should.be.false sut.validated?.should.be.false
end end
it "respects quick mode" do it 'respects quick mode' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file) sut = Validator.new(file)
sut.quick = true sut.quick = true
...@@ -72,7 +72,7 @@ module Pod ...@@ -72,7 +72,7 @@ module Pod
sut.validate sut.validate
end end
it "respects the only errors option" do it 'respects the only errors option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",') podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec) file = write_podspec(podspec)
sut = Validator.new(file) sut = Validator.new(file)
...@@ -83,21 +83,21 @@ module Pod ...@@ -83,21 +83,21 @@ module Pod
sut.validated?.should.be.true sut.validated?.should.be.true
end end
it "handles symlinks" do it 'handles symlinks' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
validator = Validator.new(file) validator = Validator.new(file)
validator.quick = true validator.quick = true
validator.stubs(:validate_url) validator.stubs(:validate_url)
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
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Extensive analysis" do describe 'Extensive analysis' do
describe "URL validation" do describe 'URL validation' do
before do before do
@sut = Validator.new(podspec_path) @sut = Validator.new(podspec_path)
@sut.stubs(:install_pod) @sut.stubs(:install_pod)
...@@ -108,61 +108,61 @@ module Pod ...@@ -108,61 +108,61 @@ module Pod
WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404) WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404)
end end
describe "Homepage validation" do describe 'Homepage validation' do
it "checks if the homepage is valid" do it 'checks if the homepage is valid' do
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 URL (.*) 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 URL/ @sut.results.map(&:to_s).first.should.match /There was a problem validating the URL/
end end
it "does not fail if the homepage redirects" do it 'does not fail if the homepage redirects' do
WebMock::API.stub_request(:head, /redirect/).to_return( WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 301, :headers => { 'Location' => 'http://banana-corp.local/found/' } ) :status => 301, :headers => { 'Location' => 'http://banana-corp.local/found/' })
WebMock::API.stub_request(:head, /found/).to_return( :status => 200 ) WebMock::API.stub_request(:head, /found/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/redirect/') Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/redirect/')
@sut.validate @sut.validate
@sut.results.length.should.equal 0 @sut.results.length.should.equal 0
end end
it "does not fail if the homepage does not support HEAD" do 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(:head, /page/).to_return(:status => 405)
WebMock::API.stub_request(:get, /page/).to_return( :status => 200 ) WebMock::API.stub_request(:get, /page/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/') Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate @sut.validate
@sut.results.length.should.equal 0 @sut.results.length.should.equal 0
end end
it "does not fail if the homepage errors on HEAD" do 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(:head, /page/).to_return(:status => 500)
WebMock::API.stub_request(:get, /page/).to_return( :status => 200 ) WebMock::API.stub_request(:get, /page/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/') Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate @sut.validate
@sut.results.length.should.equal 0 @sut.results.length.should.equal 0
end end
it "does not follow redirects infinitely" do it 'does not follow redirects infinitely' do
WebMock::API.stub_request(:head, /redirect/).to_return( WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 301, :status => 301,
:headers => { 'Location' => 'http://banana-corp.local/redirect/' } ) :headers => { 'Location' => 'http://banana-corp.local/redirect/' })
Specification.any_instance.stubs(:homepage).returns( Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect/') 'http://banana-corp.local/redirect/')
@sut.validate @sut.validate
@sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/ @sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
end end
it "supports relative redirects" do it 'supports relative redirects' do
WebMock::API.stub_request(:head, /redirect/).to_return( WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 302, :status => 302,
:headers => { 'Location' => '/foo' }) :headers => { 'Location' => '/foo' })
WebMock::API.stub_request(:head, /foo/).to_return( WebMock::API.stub_request(:head, /foo/).to_return(
:status => 200 ) :status => 200)
Specification.any_instance.stubs(:homepage).returns( Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect') 'http://banana-corp.local/redirect')
@sut.validate @sut.validate
...@@ -170,19 +170,19 @@ module Pod ...@@ -170,19 +170,19 @@ module Pod
end end
end end
describe "Screenshot validation" do describe 'Screenshot validation' do
before do before do
@sut.stubs(:validate_homepage) @sut.stubs(:validate_homepage)
WebMock::API.stub_request(:head, 'banana-corp.local/valid-image.png').to_return(:status => 200, :headers => { 'Content-Type' => 'image/png' }) WebMock::API.stub_request(:head, 'banana-corp.local/valid-image.png').to_return(:status => 200, :headers => { 'Content-Type' => 'image/png' })
end end
it "checks if the screenshots are valid" do it 'checks if the screenshots are valid' do
Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png']) Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png'])
@sut.validate @sut.validate
@sut.results.should.be.empty? @sut.results.should.be.empty?
end end
it "should fail if any of the screenshots URLS do not return an image" do 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) 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/']) Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png', 'http://banana-corp.local/'])
@sut.validate @sut.validate
...@@ -190,12 +190,12 @@ module Pod ...@@ -190,12 +190,12 @@ module Pod
end end
end end
describe "social media URL validation" do describe 'social media URL validation' do
before do before do
@sut.stubs(:validate_homepage) @sut.stubs(:validate_homepage)
end end
it "checks if the social media URL is valid" do it 'checks if the social media URL is valid' do
Specification.any_instance.stubs(:social_media_urlon_url).returns('http://banana-corp.local/') Specification.any_instance.stubs(:social_media_urlon_url).returns('http://banana-corp.local/')
WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200) WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200)
@sut.validate @sut.validate
...@@ -210,12 +210,12 @@ module Pod ...@@ -210,12 +210,12 @@ module Pod
end end
end end
describe "documentation URL validation" do describe 'documentation URL validation' do
before do before do
@sut.stubs(:validate_homepage) @sut.stubs(:validate_homepage)
end end
it "checks if the documentation URL is valid" do it 'checks if the documentation URL is valid' do
Specification.any_instance.stubs(:documentation_url).returns('http://banana-corp.local/') Specification.any_instance.stubs(:documentation_url).returns('http://banana-corp.local/')
WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200) WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200)
@sut.validate @sut.validate
...@@ -229,12 +229,12 @@ module Pod ...@@ -229,12 +229,12 @@ module Pod
end end
end end
describe "docset URL validation" do describe 'docset URL validation' do
before do before do
@sut.stubs(:validate_homepage) @sut.stubs(:validate_homepage)
end end
it "checks if the docset URL is valid" do it 'checks if the docset URL is valid' do
Specification.any_instance.stubs(:docset_url).returns('http://banana-corp.local/') Specification.any_instance.stubs(:docset_url).returns('http://banana-corp.local/')
WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200) WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200)
@sut.validate @sut.validate
...@@ -249,7 +249,7 @@ module Pod ...@@ -249,7 +249,7 @@ module Pod
end end
end end
it "respects the no clean option" do it 'respects the no clean option' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:validate_url) sut.stubs(:validate_url)
...@@ -258,7 +258,7 @@ module Pod ...@@ -258,7 +258,7 @@ module Pod
sut.validation_dir.should.exist sut.validation_dir.should.exist
end end
it "builds the pod per platform" do it 'builds the pod per platform' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:validate_url) sut.stubs(:validate_url)
...@@ -268,35 +268,35 @@ module Pod ...@@ -268,35 +268,35 @@ module Pod
sut.validate sut.validate
end end
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_url) sut.stubs(:validate_url)
sut.stubs(:validate_screenshots) 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.key?(:podspec).should.be.true
end end
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_url) sut.stubs(:validate_url)
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'
end end
it "uses xcodebuild to generate notes and warnings" do it 'uses xcodebuild to generate notes and warnings' do
sut = Validator.new(podspec_path) sut = Validator.new(podspec_path)
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_url) sut.stubs(:validate_url)
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]'
sut.result_type.should == :note sut.result_type.should == :note
end end
it "checks for file patterns" do it 'checks for file patterns' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",')) file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",'))
sut = Validator.new(file) sut = Validator.new(file)
sut.stubs(:build_pod) sut.stubs(:build_pod)
...@@ -306,11 +306,11 @@ module Pod ...@@ -306,11 +306,11 @@ module Pod
sut.result_type.should == :error sut.result_type.should == :error
end end
it "validates a podspec with dependencies" do it 'validates a podspec with dependencies' do
podspec = stub_podspec(/.*name.*/, '"name": "ZKit",') podspec = stub_podspec(/.*name.*/, '"name": "ZKit",')
podspec.gsub!(/.*requires_arc.*/, '"dependencies": { "SBJson": [ "~> 3.2" ] }, "requires_arc": false') podspec.gsub!(/.*requires_arc.*/, '"dependencies": { "SBJson": [ "~> 3.2" ] }, "requires_arc": false')
podspec.gsub!(/.*license.*$/, '"license": "Public Domain",') podspec.gsub!(/.*license.*$/, '"license": "Public Domain",')
file = write_podspec(podspec, "ZKit.podspec.json") file = write_podspec(podspec, 'ZKit.podspec.json')
spec = Specification.from_file(file) spec = Specification.from_file(file)
sut = Validator.new(spec) sut = Validator.new(spec)
......
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