Commit b64c0c1f authored by Eloy Duran's avatar Eloy Duran

Fix command specs

parent ed5e5674
......@@ -23,7 +23,7 @@ module Pod
end
class ARGV < Array
def options; select { |x| x[0,1] == '-' }; end
def options; select { |x| x.to_s[0,1] == '-' }; end
def arguments; self - options; end
def option(name); !!delete(name); end
def shift_argument; (arg = arguments[0]) && delete(arg); end
......
......@@ -21,7 +21,7 @@ module Pod
end
def add_master_repo_command
@command ||= Repo.new('add', 'master', master_repo_url)
@command ||= Repo.new(ARGV.new(['add', 'master', master_repo_url]))
end
def run
......
require File.expand_path('../../spec_helper', __FILE__)
require 'executioner'
describe "Pod::Command" do
extend SpecHelper::Fixture
extend SpecHelper::Git
extend SpecHelper::Log
extend SpecHelper::TemporaryDirectory
......@@ -14,33 +12,30 @@ describe "Pod::Command" do
it "creates the local spec-repos directory and creates a clone of the `master' repo" do
command = Pod::Command.parse('setup')
def command.master_repo_url; SpecHelper.fixture('master-spec-repo.git'); end
def (command.add_master_repo_command).repos_dir; SpecHelper.tmp_repos_path; end
command.run
git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git')
git_config('master', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s
end
def command(*argv)
command = Pod::Command.parse(*argv)
def command.repos_dir; SpecHelper.tmp_repos_path; end
command.run
command
end
it "adds a spec-repo" do
command('repo', 'add', 'private', fixture('master-spec-repo.git'))
git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git')
git_config('private', 'remote.origin.url').should == fixture('master-spec-repo.git').to_s
end
it "updates a spec-repo" do
repo1 = command('repo', 'add', 'repo1', fixture('master-spec-repo.git'))
repo2 = command('repo', 'add', 'repo2', repo1.dir)
File.open(File.join(repo1.dir, 'README'), 'a') { |f| f << 'updated!' }
(repo1.dir + 'README').open('a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"')
command('repo', 'update', 'repo2')
File.read(File.join(repo2.dir, 'README')).should.include 'updated!'
(repo2.dir + 'README').read.should.include 'updated!'
end
it "updates all the spec-repos" do
......@@ -48,11 +43,11 @@ describe "Pod::Command" do
repo2 = command('repo', 'add', 'repo2', repo1.dir)
repo3 = command('repo', 'add', 'repo3', repo1.dir)
File.open(File.join(repo1.dir, 'README'), 'a') { |f| f << 'updated!' }
(repo1.dir + 'README').open('a') { |f| f << 'updated!' }
git('repo1', 'commit -a -m "update"')
command('repo', 'update')
File.read(File.join(repo2.dir, 'README')).should.include 'updated!'
File.read(File.join(repo3.dir, 'README')).should.include 'updated!'
(repo2.dir + 'README').read.should.include 'updated!'
(repo3.dir + 'README').read.should.include 'updated!'
end
end
......@@ -8,12 +8,12 @@ module SpecHelper
module Git
def tmp_repos_path
File.join(SpecHelper.temporary_directory, 'cocoa-pods')
SpecHelper.temporary_directory + 'cocoa-pods'
end
module_function :tmp_repos_path
def tmp_master_repo_path
File.join(tmp_repos_path, 'master')
tmp_repos_path + 'master'
end
include Executioner
......@@ -21,7 +21,7 @@ module SpecHelper
alias_method :git_super, :git
def git(repo, command)
Dir.chdir(File.join(tmp_repos_path, repo)) { git_super(command).strip }
Dir.chdir(tmp_repos_path + repo) { git_super(command).strip }
end
def git_config(repo, attr)
......
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