require_relative '../spec_helper' describe 'xcbootstrap' do before(:all) do @xcbootstrap = File.expand_path(File.join(File.dirname(__FILE__), '../../bin/xcbootstrap')) end context 'with no arguments' do it 'should run successfully' do status, _ = run_command("#{@xcbootstrap}") status.should be_true end it 'should print usage information' do _, output = run_command("#{@xcbootstrap}") output.should include("Commands:") output.should include("xcbootstrap help") output.should include("xcbootstrap create") output.should include("xcbootstrap list") end end context 'when retrieving help on one of the available commands' do it 'should have a help option' do status, _ = run_command("#{@xcbootstrap} help") status.should be_true end it 'should print available help for that command' do _, help_output = run_command("#{@xcbootstrap} help") _, default_output = run_command("#{@xcbootstrap}") help_output.should == default_output end it 'should have a help option for specific commands' do status, _ = run_command("#{@xcbootstrap} help list") status.should be_true end it 'should show usage information for a specific commands' do _, output = run_command("#{@xcbootstrap} help list") output.should include("Usage:") output.should include("xcbootstrap list") end end context 'with the list argument' do it 'should run successfully' do status, _ = run_command("#{@xcbootstrap} list") status.should be_true end it 'should list all the available templates' do _, output = run_command("#{@xcbootstrap} list") output.should include("Templates:") output.should include("Sample") end end context 'with the create argument' do context 'with a valid template option specified' do context 'without the project option' do it 'should not run successfully' do status, _ = run_command("#{@xcbootstrap} create simple") status.should be_false end end context 'with the project option' do before(:all) do @test_output_directory = File.join(File.dirname(__FILE__), '../../test_output') @bootstrap_output = File.join(@test_output_directory, '/Output') FileUtils.rm_rf @test_output_directory FileUtils.mkdir_p @test_output_directory Dir.chdir(@test_output_directory) do @status, @output = run_command("#{@xcbootstrap} create Sample Output") end end it 'should run successfully' do @status.should be_true end it 'should have created the output directory' do File.exists?(@bootstrap_output).should be_true end it 'should have created source and test directories' do File.directory?(File.join(@bootstrap_output, "Output")).should be_true File.directory?(File.join(@bootstrap_output, "OutputTests")).should be_true end it 'should have created all the project files' do output_files = Dir.glob("#{@bootstrap_output}/**/{.*,*}").select { |file| !File.directory?(file) } output_files.size.should == 13 end it 'should have the git ignore file renamed' do File.exists?(File.join(@bootstrap_output, ".gitignore")).should be_true end it 'should have replaced the template with the project name' do content = File.read(File.join(@bootstrap_output, "Output.xcodeproj/project.pbxproj")) content.should_not include("Sample") content.should include("Output") end it' should print out the list of files created in the new project' do @output.should include("...project.pbxproj") end it 'should print out the next steps information' do @output.should include("** Next steps **") end end end context 'with a non-existant template option specified' do it 'should not run successfully' do status, _ = run_command("#{@xcbootstrap} create a-non-existant-template-name") status.should be_false end end context 'without no template option specified' do it 'should run successfully' do status, _ = run_command("#{@xcbootstrap} create") status.should be_true end it 'should print usage information' do _, output = run_command("#{@xcbootstrap} create") output.should include("Commands:") output.should include("xcbootstrap create") end end end end