require File.expand_path('../../../spec_helper', __FILE__)

module Pod
  describe Command::Init do

    it "runs with no parameters" do
      lambda { run_command('init') }.should.not.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
    end

    extend SpecHelper::TemporaryRepos

    it "creates a Podfile" do
      run_command('init')
      path = temporary_directory + 'Podfile'
      File.exists?(path).should == true
    end
  end
end

require File.expand_path('../../../spec_helper', __FILE__)

require 'xcodeproj'

module Pod

  describe Command::Init do

    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 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

    it "creates a Podfile for a project in current directory" do
      pwd = Dir.pwd
      Dir.chdir(temporary_directory)

      Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
      run_command('init')
      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

Add a more thorough spec for init command.
Add a more thorough spec for init command.
