Commit 66946a7f authored by Ian Ynda-Hummel's avatar Ian Ynda-Hummel

Add a more thorough spec for init command.

parent 88af9c25
require File.expand_path('../../../spec_helper', __FILE__)
require 'xcodeproj'
module Pod
describe Command::Init do
it "runs with no parameters" do
lambda { run_command('init') }.should.not.raise CLAide::Help
it "complains if project does not exist" do
lambda { run_command('init') }.should.raise CLAide::Help
lambda { run_command('init', 'foo.xcodeproj') }.should.raise CLAide::Help
end
it "complains if wrong parameters" do
lambda { run_command('too', 'many') }.should.raise CLAide::Help
end
it "complains when given parameters" do
lambda { run_command('init', 'create') }.should.raise CLAide::Help
lambda { run_command('init', '--create') }.should.raise CLAide::Help
lambda { run_command('init', 'NAME') }.should.raise CLAide::Help
lambda { run_command('init', 'createa') }.should.raise CLAide::Help
lambda { run_command('init', 'agument1', '2') }.should.raise CLAide::Help
lambda { run_command('init', 'which') }.should.raise CLAide::Help
lambda { run_command('init', 'cat') }.should.raise CLAide::Help
lambda { run_command('init', 'edit') }.should.raise CLAide::Help
it "complains if more than one project exists and none is specified" do
pwd = Dir.pwd
Dir.chdir(temporary_directory)
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj')
lambda { run_command('init') }.should.raise CLAide::Help
Dir.chdir(pwd)
end
extend SpecHelper::TemporaryRepos
it "creates a Podfile for a project in current directory" do
pwd = Dir.pwd
Dir.chdir(temporary_directory)
it "creates a Podfile" do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
run_command('init')
path = temporary_directory + 'Podfile'
File.exists?(path).should == true
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
Dir.chdir(pwd)
end
it "creates a Podfile for a specified project" do
pwd = Dir.pwd
Dir.chdir(temporary_directory)
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj')
run_command('init', 'test2.xcodeproj')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
Dir.chdir(pwd)
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