Commit b64c0c1f authored by Eloy Duran's avatar Eloy Duran

Fix command specs

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