Commit dcd537a5 authored by Eloy Duran's avatar Eloy Duran

Fix command unit specs.

parent b64c0c1f
...@@ -48,7 +48,7 @@ module Pod ...@@ -48,7 +48,7 @@ module Pod
end end
def add def add
puts "==> Cloning spec repo `#{@name}' from `#{@url}'" puts "==> Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
config.repos_dir.mkpath config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git("clone #{@url} #{@name}") } Dir.chdir(config.repos_dir) { git("clone #{@url} #{@name}") }
end end
...@@ -56,7 +56,7 @@ module Pod ...@@ -56,7 +56,7 @@ module Pod
def update def update
dirs = @name ? [dir] : config.repos_dir.children dirs = @name ? [dir] : config.repos_dir.children
dirs.each do |dir| dirs.each do |dir|
puts "==> Updating spec repo `#{dir.basename}'" puts "==> Updating spec repo `#{dir.basename}'" unless config.silent?
Dir.chdir(dir) { git("pull") } Dir.chdir(dir) { git("pull") }
end end
end end
......
...@@ -10,12 +10,16 @@ module Pod ...@@ -10,12 +10,16 @@ module Pod
@instance = instance @instance = instance
end end
attr_accessor :repos_dir, :clean, :verbose attr_accessor :repos_dir, :clean, :verbose, :silent
alias_method :clean?, :clean
alias_method :verbose?, :verbose
alias_method :silent?, :silent
def initialize def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoa-pods")) @repos_dir = Pathname.new(File.expand_path("~/.cocoa-pods"))
@clean = true @clean = true
@verbose = false @verbose = false
@silent = false
end end
def project_root def project_root
......
...@@ -24,7 +24,9 @@ module Pod ...@@ -24,7 +24,9 @@ module Pod
end end
def install! def install!
puts "Installing dependencies defined in: #{@top_level_specification.defined_in_file}" unless config.silent?
puts "Installing dependencies defined in: #{@top_level_specification.defined_in_file}"
end
install_dependent_specifications! install_dependent_specifications!
generate_project generate_project
write_files! write_files!
...@@ -40,7 +42,7 @@ module Pod ...@@ -40,7 +42,7 @@ module Pod
end end
def generate_project def generate_project
puts "==> Creating Pods project files" puts "==> Creating Pods project files" unless config.silent?
dependent_specification_sets.each do |set| dependent_specification_sets.each do |set|
# In case the set is only part of other pods we don't need to build # In case the set is only part of other pods we don't need to build
# the pod itself. # the pod itself.
......
...@@ -145,7 +145,7 @@ module Pod ...@@ -145,7 +145,7 @@ module Pod
# end # end
# end # end
def install! def install!
puts "==> Installing: #{self}" puts "==> Installing: #{self}" unless config.silent?
config.project_pods_root.mkpath config.project_pods_root.mkpath
require 'fileutils' require 'fileutils'
FileUtils.cp(@defined_in_file, config.project_pods_root) FileUtils.cp(@defined_in_file, config.project_pods_root)
...@@ -157,9 +157,9 @@ module Pod ...@@ -157,9 +157,9 @@ module Pod
def download_if_necessary! def download_if_necessary!
if pod_destroot.exist? if pod_destroot.exist?
puts " * Skipping download of #{self}, pod already downloaded" puts " * Skipping download of #{self}, pod already downloaded" unless config.silent?
else else
puts " * Downloading: #{self}" puts " * Downloading: #{self}" unless config.silent?
download! download!
end end
end end
......
...@@ -20,6 +20,12 @@ class Bacon::Context ...@@ -20,6 +20,12 @@ class Bacon::Context
include Pod::Config::Mixin include Pod::Config::Mixin
include SpecHelper::Fixture include SpecHelper::Fixture
def argv(*argv)
Pod::Command::ARGV.new(argv)
end
end end
Pod::Config.instance.repos_dir = SpecHelper.tmp_repos_path config = Pod::Config.instance
config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path
...@@ -2,34 +2,25 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,34 +2,25 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Command" do describe "Pod::Command" do
it "returns the proper command class" do it "returns the proper command class" do
Pod::Command.parse("help").should.be.instance_of Pod::Command::Help Pod::Command.parse('setup').should.be.instance_of Pod::Command::Setup
Pod::Command.parse("setup").should.be.instance_of Pod::Command::Setup #Pod::Command.parse('spec').should.be.instance_of Pod::Command::Spec
Pod::Command.parse("spec").should.be.instance_of Pod::Command::Spec Pod::Command.parse('repo', 'update').should.be.instance_of Pod::Command::Repo
Pod::Command.parse("repo").should.be.instance_of Pod::Command::Repo
end end
end end
describe "Pod::Command::Setup" do describe "Pod::Command::Setup" do
it "complains about unknown arguments" do it "complains about unknown arguments" do
lambda { Pod::Command::Setup.new('something') }.should.raise ArgumentError lambda { Pod::Command::Setup.new(argv('something')) }.should.raise Pod::Command::Help
end
before do
@command = Pod::Command::Setup.new
end end
it "returns the URL of the `master' spec-repo" do it "returns the URL of the `master' spec-repo" do
@command.master_repo_url.should == 'git://github.com/alloy/cocoa-pod-specs.git' command = Pod::Command::Setup.new(argv)
command.master_repo_url.should == 'git://github.com/alloy/cocoa-pod-specs.git'
end end
end end
describe "Pod::Command::Repo" do describe "Pod::Command::Repo" do
it "complains about unknown arguments" do it "complains about unknown arguments" do
lambda { Pod::Command::Repo.new('something') }.should.raise ArgumentError lambda { Pod::Command::Repo.new(argv('something')) }.should.raise Pod::Command::Help
end
it "returns the path of the spec-repo directory" do
repo = Pod::Command::Repo.new('cd', 'private')
repo.dir.should == File.join(config.repos_dir, 'private')
end end
end end
...@@ -33,12 +33,16 @@ describe "Pod::Config" do ...@@ -33,12 +33,16 @@ describe "Pod::Config" do
end end
describe "concerning default settings" do describe "concerning default settings" do
it "prints out normal information" do
config.should.not.be.silent
end
it "does not print vebose information" do it "does not print vebose information" do
config.verbose.should == false config.should.not.be.verbose
end end
it "cleans SCM dirs in dependency checkouts" do it "cleans SCM dirs in dependency checkouts" do
config.clean.should == true config.should.clean
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment