Commit b255de76 authored by Eloy Durán's avatar Eloy Durán

Make specs green.

parent 054fe5c8
...@@ -8,7 +8,7 @@ GIT ...@@ -8,7 +8,7 @@ GIT
GIT GIT
remote: git://github.com/alloy/CLAide.git remote: git://github.com/alloy/CLAide.git
revision: fdcc73837ff0c67b440fa9a20dc6366c78f06f09 revision: 324ceaf81365eb6e5936c010037887a2c8d44f3e
specs: specs:
claide (0.0.1) claide (0.0.1)
......
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
lint_argv << "--silent" if config.silent lint_argv << "--silent" if config.silent
all_valid = true all_valid = true
podspec_files.each do |podspec| podspec_files.each do |podspec|
Spec.new(ARGV.new(lint_argv + [podspec.to_s])).run Spec.parse(lint_argv + [podspec.to_s]).run
end end
end end
......
...@@ -149,17 +149,10 @@ module Pod ...@@ -149,17 +149,10 @@ module Pod
# TODO some of the following methods can probably move to one of the subclasses. # TODO some of the following methods can probably move to one of the subclasses.
protected
def dir def dir
config.repos_dir + @name config.repos_dir + @name
end end
def print_messages(type, messages)
return if config.silent?
messages.each {|msg| UI.puts " - #{type.ljust(5)} | #{msg}"}
end
def check_versions(dir) def check_versions(dir)
versions = versions(dir) versions = versions(dir)
unless is_compatilbe(versions) unless is_compatilbe(versions)
...@@ -172,6 +165,13 @@ module Pod ...@@ -172,6 +165,13 @@ module Pod
UI.puts "\nCocoapods #{versions['last']} is available.\n".green if has_update(versions) && config.new_version_message? UI.puts "\nCocoapods #{versions['last']} is available.\n".green if has_update(versions) && config.new_version_message?
end end
protected
def print_messages(type, messages)
return if config.silent?
messages.each {|msg| UI.puts " - #{type.ljust(5)} | #{msg}"}
end
def self.compatible?(name) def self.compatible?(name)
dir = Config.instance.repos_dir + name dir = Config.instance.repos_dir + name
versions = versions(dir) versions = versions(dir)
......
...@@ -69,7 +69,7 @@ module Pod ...@@ -69,7 +69,7 @@ module Pod
end end
def add_master_repo def add_master_repo
@command ||= Repo.new(ARGV.new(['add', 'master', url, 'master'])).run @command ||= Repo::Add.parse(['master', url, 'master']).run
end end
def update_master_repo def update_master_repo
......
...@@ -5,6 +5,8 @@ require 'active_support/core_ext/string/inflections' ...@@ -5,6 +5,8 @@ require 'active_support/core_ext/string/inflections'
module Pod module Pod
class Command class Command
class Spec < Command class Spec < Command
self.abstract_command = true
self.summary = 'Manage pod specs' self.summary = 'Manage pod specs'
class Create < Spec class Create < Spec
...@@ -18,7 +20,7 @@ module Pod ...@@ -18,7 +20,7 @@ module Pod
self.arguments = '[ NAME | https://github.com/USER/REPO ]' self.arguments = '[ NAME | https://github.com/USER/REPO ]'
def initialize(argv) def initialize(argv)
@url, @name_or_url = argv.shift_argument, argv.shift_argument @name_or_url, @url = argv.shift_argument, argv.shift_argument
super super
end end
......
...@@ -82,7 +82,7 @@ module Pod ...@@ -82,7 +82,7 @@ module Pod
unless config.skip_repo_update? unless config.skip_repo_update?
UI.section 'Updating spec repositories' do UI.section 'Updating spec repositories' do
Command::Repo.new(Command::ARGV.new(["update"])).run Command::Repo::Update.parse([]).run
end if !@lockfile || !(@pods_by_state[:added] + @pods_by_state[:changed]).empty? || update_mode end if !@lockfile || !(@pods_by_state[:added] + @pods_by_state[:changed]).empty? || update_mode
end end
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Install" do module Pod
extend SpecHelper::Command describe Command::Install do
extend SpecHelper::TemporaryDirectory it "tells the user that no Podfile or podspec was found in the current working dir" do
extend SpecHelper::TemporaryRepos exception = lambda { run_command('install', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory."
it "should include instructions on how to reference the xcode project" do end
Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/XcodeProject'}
end
it "tells the user that no Podfile or podspec was found in the current working dir" do
exception = lambda { run_command('install','--no-update') }.should.raise Pod::Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::List" do module Pod
extend SpecHelper::TemporaryRepos describe Command::List do
extend SpecHelper::TemporaryRepos
def command(arguments = argv) it "lists the known pods" do
command = Pod::Command::List.new(arguments) out = run_command('list')
end [ /ZBarSDK/,
/TouchJSON/,
it "complains for wrong parameters" do /SDURLCache/,
lambda { command(argv('wrong')).run }.should.raise Pod::Command::Help /MagicalRecord/,
lambda { command(argv('--wrong')).run }.should.raise Pod::Command::Help /A2DynamicDelegate/,
end /\d+ pods were found/
].each { |regex| out.should =~ regex }
end
it "presents the known pods" do it "lists the new pods" do
list = command() Time.stubs(:now).returns(Time.mktime(2012,2,3))
list.run out = run_command('list', 'new')
[ /ZBarSDK/, [ 'iCarousel',
/TouchJSON/, 'libPusher',
/SDURLCache/, 'SSCheckBoxView',
/MagicalRecord/, 'KKPasscodeLock',
/A2DynamicDelegate/, 'SOCKit',
/\d+ pods were found/ 'FileMD5Hash',
].each { |regex| Pod::UI.output.should =~ regex } 'cocoa-oauth',
end 'iRate'
].each {|s| out.should.include s }
it "returns the new pods" do end
Time.stubs(:now).returns(Time.mktime(2012,2,3))
list = command(argv('new'))
list.run
[ 'iCarousel',
'libPusher',
'SSCheckBoxView',
'KKPasscodeLock',
'SOCKit',
'FileMD5Hash',
'cocoa-oauth',
'iRate'
].each {|s| Pod::UI.output.should.include s }
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Outdated do module Pod
extend SpecHelper::Command describe Command::Outdated do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
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-update') }.should.raise Pod::Informative exception = lambda { run_command('outdated', '--no-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-update') }.should.raise Pod::Informative exception = lambda { run_command('outdated', '--no-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"
end
end end
end end
end end
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Push do module Pod
extend SpecHelper::Command describe Command::Push do
extend SpecHelper::TemporaryDirectory extend SpecHelper::Command
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
def master_repo def master_repo
fixture('spec-repos/master') fixture('spec-repos/master')
end end
it "complains for wrong parameters" do it "requires a spec-repo name" do
lambda { run_command('push') }.should.raise Pod::Command::Help lambda { command('push').validate! }.should.raise Command::Help
lambda { run_command('push', '--allow-warnings') }.should.raise Pod::Command::Help end
lambda { run_command('push', '--wrong-option') }.should.raise Pod::Command::Help
end
it "complains if it can't find the repo" do it "complains if it can't find the repo" do
repo1 = add_repo('repo1', master_repo) repo1 = add_repo('repo1', master_repo)
Dir.chdir(fixture('banana-lib')) do Dir.chdir(fixture('banana-lib')) do
lambda { run_command('push', 'repo2') }.should.raise Pod::Informative lambda { run_command('push', 'repo2') }.should.raise Informative
end
end end
end
it "complains if it can't find a spec" do it "complains if it can't find a spec" do
repo1 = add_repo('repo1', master_repo) repo1 = add_repo('repo1', master_repo)
lambda { run_command('push', 'repo1') }.should.raise Pod::Informative lambda { run_command('push', 'repo1') }.should.raise Informative
end end
it "it raises if the pod is not validated" do it "it raises if the pod is not validated" do
repo1 = add_repo('repo1', master_repo) repo1 = add_repo('repo1', master_repo)
repo2 = add_repo('repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s
Dir.chdir(fixture('banana-lib')) do Dir.chdir(fixture('banana-lib')) do
lambda { command('push', 'repo2', '--silent').run }.should.raise Pod::Informative lambda { run_command('push', 'repo2', '--silent') }.should.raise Informative
end
# (repo1.dir + 'BananaLib/1.0/BananaLib.podspec').read.should.include 'Added!'
end end
# (repo1.dir + 'BananaLib/1.0/BananaLib.podspec').read.should.include 'Added!'
end
before do before do
# prepare the repos # prepare the repos
@upstream = add_repo('upstream', master_repo) @upstream = add_repo('upstream', master_repo)
@local_repo = add_repo('local_repo', @upstream.dir) @local_repo = add_repo('local_repo', @upstream.dir)
git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s
# prepare the spec # prepare the spec
spec = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read spec = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read
spec_fix = spec.gsub(/https:\/\/github\.com\/johnezang\/JSONKit\.git/, fixture('integration/JSONKit').to_s) spec_fix = spec.gsub(/https:\/\/github\.com\/johnezang\/JSONKit\.git/, fixture('integration/JSONKit').to_s)
spec_add = spec.gsub(/'JSONKit'/, "'PushTest'") spec_add = spec.gsub(/'JSONKit'/, "'PushTest'")
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) }
end end
it "refuses to push if the repo is not clean" do it "refuses to push if the repo is not clean" do
File.open(@local_repo.dir + 'README', 'w') {|f| f.write('Added!') } File.open(@local_repo.dir + 'README', 'w') {|f| f.write('Added!') }
(@local_repo.dir + 'README').read.should.include 'Added!' (@local_repo.dir + 'README').read.should.include 'Added!'
cmd = command('push', 'local_repo') cmd = command('push', 'local_repo')
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { lambda { cmd.run }.should.raise Pod::Informative } Dir.chdir(temporary_directory) { lambda { cmd.run }.should.raise Informative }
(@upstream.dir + 'PushTest/1.4/PushTest.podspec').should.not.exist? (@upstream.dir + 'PushTest/1.4/PushTest.podspec').should.not.exist?
end end
it "sucessfully pushes a spec" do it "sucessfully pushes a spec" do
git('upstream', 'checkout master') # checkout master, to allow push in a non-bare repository git('upstream', 'checkout master') # checkout master, to allow push in a non-bare repository
cmd = command('push', 'local_repo') cmd = command('push', 'local_repo')
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run } Dir.chdir(temporary_directory) { cmd.run }
Pod::UI.output.should.include('[Add] PushTest (1.4)') UI.output.should.include('[Add] PushTest (1.4)')
Pod::UI.output.should.include('[Fix] JSONKit (1.4)') UI.output.should.include('[Fix] JSONKit (1.4)')
git('upstream', 'checkout test') # checkout because test because is it the branch used in the specs. git('upstream', 'checkout test') # checkout because test because is it the branch used in the specs.
(@upstream.dir + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest') (@upstream.dir + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest')
end
end end
end end
...@@ -7,20 +7,9 @@ describe "Pod::Command::Repo" do ...@@ -7,20 +7,9 @@ describe "Pod::Command::Repo" do
end end
describe "In general" do describe "In general" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do
lambda { run_command('repo', 'update') }.should.not.raise
lambda { run_command('repo', 'lint', temporary_directory.to_s) }.should.not.raise
end
it "complains for wrong parameters" do
lambda { run_command('repo', 'add') }.should.raise Pod::Informative
lambda { run_command('repo', 'add', 'NAME') }.should.raise Pod::Informative
end
it "adds a spec-repo" do it "adds a spec-repo" do
run_command('repo', 'add', 'private', fixture('spec-repos/master')) run_command('repo', 'add', 'private', fixture('spec-repos/master'))
git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
...@@ -67,7 +56,6 @@ describe "Pod::Command::Repo" do ...@@ -67,7 +56,6 @@ describe "Pod::Command::Repo" do
end end
describe "Concerning a repo support" do describe "Concerning a repo support" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Search" do module Pod
extend SpecHelper::Command describe Command::Search do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('search', 'table') }.should.not.raise lambda { run_command('search', 'table') }.should.not.raise
lambda { run_command('search', 'table', '--full') }.should.not.raise lambda { run_command('search', 'table', '--full') }.should.not.raise
end end
it "complains for wrong parameters" do it "complains for wrong parameters" do
lambda { run_command('search') }.should.raise Pod::Command::Help lambda { run_command('search') }.should.raise Command::Help
lambda { run_command('search', 'too', 'many') }.should.raise Pod::Command::Help lambda { run_command('search', 'too', 'many') }.should.raise Command::Help
lambda { run_command('search', 'too', '--wrong') }.should.raise Pod::Command::Help lambda { run_command('search', 'too', '--wrong') }.should.raise Command::Help
lambda { run_command('search', '--wrong') }.should.raise Pod::Command::Help lambda { run_command('search', '--wrong') }.should.raise Command::Help
end end
it "presents the search results" do it "presents the search results" do
output = run_command('search', 'table') output = run_command('search', 'table')
output.should.include 'EGOTableViewPullRefresh' output.should.include 'EGOTableViewPullRefresh'
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
[ [
[' s ', %w{ ASIHTTPRequest ASIWebPageRequest JSONKit SSZipArchive }], [' s ', %w{ ASIHTTPRequest ASIWebPageRequest JSONKit SSZipArchive }],
['json', %w{ JSONKit SBJson }], ['json', %w{ JSONKit SBJson }],
].each do |query, results| ].each do |query, results|
output = run_command('search', query) output = run_command('search', query)
results.each { |pod| output.should.include? pod } results.each { |pod| output.should.include? pod }
end
end 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
[ [
['dROP', %w{ Reachability }], ['dROP', %w{ Reachability }],
['is', %w{ ASIHTTPRequest SSZipArchive }], ['is', %w{ ASIHTTPRequest SSZipArchive }],
['luke redpath', %w{ Kiwi libPusher LRMocky LRResty LRTableModel}], ['luke redpath', %w{ Kiwi libPusher LRMocky LRResty LRTableModel}],
].each do |query, results| ].each do |query, results|
output = run_command('search', '--full', query) output = run_command('search', query, '--full')
results.each { |pod| output.should.include? pod } results.each { |pod| output.should.include? pod }
end
end end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe "Pod::Command::Setup" do describe Command::Setup do
extend SpecHelper::Command extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryRepos
extend SpecHelper::TemporaryRepos
before do
before do config.repos_dir = SpecHelper.tmp_repos_path
config.repos_dir = SpecHelper.tmp_repos_path 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 "complains for wrong parameters" do
it "complains for wrong parameters" do lambda { run_command('setup', 'wrong') }.should.raise Command::Help
lambda { run_command('setup', 'wrong') }.should.raise Pod::Command::Help lambda { run_command('setup', '--wrong') }.should.raise Command::Help
lambda { run_command('setup', '--wrong') }.should.raise Pod::Command::Help 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 = Pod::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 = Pod::Command::Setup.new(argv('--push')) cmd.url.should == 'git@github.com:CocoaPods/Specs.git'
cmd.url.should == 'git@github.com:CocoaPods/Specs.git' end
end
class Command::Setup
class Pod::Command::Setup def read_only_url; SpecHelper.fixture('spec-repos/master'); end
def read_only_url; SpecHelper.fixture('spec-repos/master'); end 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" git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s 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" git('master', 'remote set-url origin git@github.com:CocoaPods/Specs.git')
git('master', '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
it "can run if needed" do
it "can run if needed" do output = run_command('setup')
output = run_command('setup') output.should.include "Setup completed"
output.should.include "Setup completed" UI.output = ''
Pod::UI.output = '' command('setup').run_if_needed
command('setup').run_if_needed UI.output.should == ''
Pod::UI.output.should == '' end
end end
end end
This diff is collapsed.
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Update do module Pod
extend SpecHelper::Command describe Command::Update do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
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-update') }.should.raise Pod::Informative exception = lambda { run_command('update','--no-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('update','--no-update') }.should.raise Pod::Informative exception = lambda { run_command('update','--no-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"
end
end end
end end
end end
......
require File.expand_path('../../spec_helper', __FILE__)
# describe "Pod::Command" do
# extend SpecHelper::Command
# extend SpecHelper::TemporaryDirectory
# extend SpecHelper::TemporaryRepos
#
# TODO:
# it "raises help informative if an unknown parameter is passed"
# it "performs setup if needed"
# end
...@@ -21,13 +21,18 @@ require 'spec_helper/temporary_repos' ...@@ -21,13 +21,18 @@ require 'spec_helper/temporary_repos'
require 'spec_helper/user_interface' require 'spec_helper/user_interface'
require 'spec_helper/pre_flight' require 'spec_helper/pre_flight'
ENV['SKIP_SETUP'] = 'true'
require 'claide'
module Bacon module Bacon
class Context class Context
include Pod::Config::Mixin include Pod::Config::Mixin
include SpecHelper::Fixture include SpecHelper::Fixture
include SpecHelper::Command
def argv(*argv) def argv(*argv)
Pod::Command::ARGV.new(argv) CLAide::ARGV.new(argv)
end end
end end
end end
......
...@@ -4,7 +4,7 @@ module SpecHelper ...@@ -4,7 +4,7 @@ module SpecHelper
module Command module Command
def command(*argv) def command(*argv)
argv << '--no-color' argv << '--no-color'
Pod::Command.parse(*argv) Pod::Command.parse(argv)
end end
def run_command(*args) def run_command(*args)
...@@ -14,7 +14,9 @@ module SpecHelper ...@@ -14,7 +14,9 @@ module SpecHelper
# been converted to use the UI.puts # been converted to use the UI.puts
config_silent = config.silent? config_silent = config.silent?
config.silent = false config.silent = false
command(*args).run cmd = command(*args)
cmd.validate!
cmd.run
config.silent = config_silent config.silent = config_silent
Pod::UI.output Pod::UI.output
end end
......
...@@ -28,7 +28,7 @@ module SpecHelper ...@@ -28,7 +28,7 @@ module SpecHelper
end end
def add_repo(name, from) def add_repo(name, from)
command = command('repo', 'add', name, from) command = Pod::Command.parse(['repo', 'add', name, from])
command.run command.run
# The test branch is used by the push specs # The test branch is used by the push specs
Dir.chdir(command.dir) do Dir.chdir(command.dir) do
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Command" do module Pod
it "returns the proper command class" do describe Command do
Pod::Command.parse('setup').should.be.instance_of Pod::Command::Setup it "returns the proper command class" do
Pod::Command.parse('spec', 'create', 'name').should.be.instance_of Pod::Command::Spec Command.parse(%w{ install }).should.be.instance_of Command::Install
Pod::Command.parse('repo', 'update').should.be.instance_of Pod::Command::Repo Command.parse(%w{ list }).should.be.instance_of Command::List
Command.parse(%w{ outdated }).should.be.instance_of Command::Outdated
Command.parse(%w{ push }).should.be.instance_of Command::Push
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 lint }).should.be.instance_of Command::Repo::Lint
Command.parse(%w{ repo update }).should.be.instance_of Command::Repo::Update
Command.parse(%w{ search }).should.be.instance_of Command::Search
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 lint }).should.be.instance_of Command::Spec::Lint
Command.parse(%w{ repo update }).should.be.instance_of Command::Repo::Update
end
end end
end end
describe "Pod::Command::Repo" do
it "complains about unknown arguments" do
lambda { Pod::Command::Repo.new(argv('something')) }.should.raise Pod::Command::Help
end
end
...@@ -14,9 +14,9 @@ module Pod ...@@ -14,9 +14,9 @@ module Pod
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
@resolver.cached_sets.values.sort_by(&:name).should == [ @resolver.cached_sets.values.sort_by(&:name).should == [
Pod::Source.search_by_name('A2DynamicDelegate').first, Source.search_by_name('A2DynamicDelegate').first,
Pod::Source.search_by_name('BlocksKit').first, Source.search_by_name('BlocksKit').first,
Pod::Source.search_by_name('libffi').first Source.search_by_name('libffi').first
].sort_by(&:name) ].sort_by(&:name)
end end
...@@ -34,7 +34,7 @@ module Pod ...@@ -34,7 +34,7 @@ module Pod
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
set = Pod::Source.search_by_name('BlocksKit').first set = Source.search_by_name('BlocksKit').first
@resolver.cached_sets['BlocksKit'] = set @resolver.cached_sets['BlocksKit'] = set
def set.stub_platform=(platform); @stubbed_platform = platform; end def set.stub_platform=(platform); @stubbed_platform = platform; end
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
end end
it "raises once any of the dependencies does not have a deployment_target compatible with its podfile target" do it "raises once any of the dependencies does not have a deployment_target compatible with its podfile target" do
set = Pod::Source.search_by_name('BlocksKit').first set = Source.search_by_name('BlocksKit').first
@resolver.cached_sets['BlocksKit'] = set @resolver.cached_sets['BlocksKit'] = set
@podfile.platform :ios, "4.0" @podfile.platform :ios, "4.0"
...@@ -200,7 +200,7 @@ module Pod ...@@ -200,7 +200,7 @@ module Pod
pod 'JSONKit', "1.5pre" pod 'JSONKit', "1.5pre"
end end
resolver = Resolver.new(podfile, nil, stub('sandbox')) resolver = Resolver.new(podfile, nil, stub('sandbox'))
lambda {resolver.resolve}.should.raise Pod::Informative lambda {resolver.resolve}.should.raise Informative
end end
describe "Concerning Installation mode" do describe "Concerning Installation mode" do
...@@ -212,11 +212,11 @@ module Pod ...@@ -212,11 +212,11 @@ module Pod
pod 'JSONKit' pod 'JSONKit'
end end
@specs = [ @specs = [
Pod::Specification.new do |s| Specification.new do |s|
s.name = "BlocksKit" s.name = "BlocksKit"
s.version = "1.0.0" s.version = "1.0.0"
end, end,
Pod::Specification.new do |s| Specification.new do |s|
s.name = "JSONKit" s.name = "JSONKit"
s.version = "1.4" s.version = "1.4"
end ] end ]
...@@ -300,7 +300,7 @@ module Pod ...@@ -300,7 +300,7 @@ module Pod
pod 'JSONKit' pod 'JSONKit'
end end
config.skip_repo_update = false config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).never Command::Repo.any_instance.expects(:run).never
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve @resolver.resolve
end end
...@@ -313,7 +313,7 @@ module Pod ...@@ -313,7 +313,7 @@ module Pod
pod 'libPusher' # New pod pod 'libPusher' # New pod
end end
config.skip_repo_update = false config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once Command::Repo::Update.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve @resolver.resolve
end end
...@@ -326,7 +326,7 @@ module Pod ...@@ -326,7 +326,7 @@ module Pod
pod 'libPusher' # New pod pod 'libPusher' # New pod
end end
config.skip_repo_update = true config.skip_repo_update = true
Pod::Command::Repo.any_instance.expects(:run).never Command::Repo::Update.any_instance.expects(:run).never
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve @resolver.resolve
end end
...@@ -338,7 +338,7 @@ module Pod ...@@ -338,7 +338,7 @@ module Pod
pod 'JSONKit', :head #changed to head pod 'JSONKit', :head #changed to head
end end
config.skip_repo_update = false config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once Command::Repo::Update.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.resolve @resolver.resolve
end end
...@@ -354,11 +354,11 @@ module Pod ...@@ -354,11 +354,11 @@ module Pod
pod 'libPusher' pod 'libPusher'
end end
@specs = [ @specs = [
Pod::Specification.new do |s| Specification.new do |s|
s.name = "libPusher" s.name = "libPusher"
s.version = "1.3" s.version = "1.3"
end, end,
Pod::Specification.new do |s| Specification.new do |s|
s.name = "JSONKit" s.name = "JSONKit"
s.version = "1.4" s.version = "1.4"
end ] end ]
...@@ -411,7 +411,7 @@ module Pod ...@@ -411,7 +411,7 @@ module Pod
pod 'libPusher' pod 'libPusher'
end end
config.skip_repo_update = false config.skip_repo_update = false
Pod::Command::Repo.any_instance.expects(:run).once Command::Repo::Update.any_instance.expects(:run).once
@resolver = Resolver.new(podfile, @lockfile, stub('sandbox')) @resolver = Resolver.new(podfile, @lockfile, stub('sandbox'))
@resolver.update_mode = true @resolver.update_mode = true
@resolver.resolve @resolver.resolve
......
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