require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'install_theme/cli' describe InstallTheme::CLI, "execute" do it("parses arguments and run generator") do theme = stub InstallTheme.should_receive(:new). with(:template_root => "path/to/template", :rails_root => "path/to/rails_app", :content_path => "#content_box", :index_path => "root.html", :template_type => "haml", :partials => { "header" => '#header h2', "sidebar" => '#sidebar' }, :defaults_file => "install_theme.yml", :layout => "iphone" ). and_return(theme) theme.should_receive(:valid?).and_return(true) theme.should_receive(:apply_to_target) @stdout = stdout do |stdout_io| InstallTheme::CLI.execute(stdout_io, %w[path/to/rails_app path/to/template #content_box --index_path=root.html --haml --partial header:#header\ h2 -p sidebar:#sidebar --defaults_file install_theme.yml --layout iphone ]) end end it("allows for content_path and partials to be derived from defaults file") do theme = stub InstallTheme.should_receive(:new). with(:template_root => "path/to/template", :rails_root => "path/to/rails_app", :content_path => nil ). and_return(theme) theme.should_receive(:valid?).and_return(true) theme.should_receive(:apply_to_target) @stdout = stdout do |stdout_io| InstallTheme::CLI.execute(stdout_io, %w[path/to/rails_app path/to/template]) end end end