require_relative '../spec_helper'

describe 'Cli' do
  before(:each) do
    fake_boostrap = mock().as_null_object
    XCBootstrap::Bootstrap.stub(:new).and_return(fake_boostrap)
  end
  
  context 'with the template and project arguments' do
    it 'should point to the default template dir' do
      default_template_dir = File.expand_path("templates")
      XCBootstrap::Bootstrap.should_receive(:new).with(default_template_dir, anything, anything)
      XCBootstrap::Cli.new("", {}).run(["--template", "MyTemplate", "--project", "../MyProject"])
    end
    
    it 'should bootstrap the project from the template' do
      XCBootstrap::Bootstrap.should_receive(:new).with(anything, "MyTemplate", "../MyProject")
      XCBootstrap::Cli.new("", {}).run(["--template", "MyTemplate", "--project", "../MyProject"])
    end
  end
  
  context 'without the template flag' do
    it 'should raise an error' do
      expect { XCBootstrap::Cli.new("", {}).run(["--project", "../MyProject"]) }.to raise_error
    end
  end
  
  context 'without the project flag' do
    it 'should raise an error' do
      expect { XCBootstrap::Cli.new("", {}).run(["--template", "MyTemplate"]) }.to raise_error
    end
  end
end