require 'spec_helper' describe 'General' do before :each do Dir.chdir("spec/blank") @cap = Capucine::Main.new @config_user = File.join @cap.settings.content_dir, 'shared', 'capucine.yaml' @config_user_coffee = File.expand_path File.join '..', 'capucine_coffee.yaml' end after :each do Dir.chdir("../..") end it '#init the Capucine' do @cap.should_not eq(nil) @cap.settings.should_not eq(nil) @cap.settings.working_dir.should eq(Dir.pwd) @cap.settings.conf.should_not eq(nil) end it '#init the Capucine with settings' do @cap.settings.set_user_config_file(@config_user) @cap.settings.should_not eq(nil) @cap.settings.working_dir.should eq(Dir.pwd) @cap.settings.user_config_file.should_not eq(nil) @cap.settings.conf.should_not eq(nil) @cap.settings.conf['use_compass'].should eq(true) @cap.settings.conf['use_coffeescript'].should eq(false) @cap.settings.conf['use_incloudr'].should eq(false) end it '#init from command line' do @cap.run_command(['i']) File.exist?('capucine.yaml').should be_true size = File.size('capucine.yaml') size.should_not == 0 FileUtils.rm_r 'capucine.yaml' end it '#update from command line' do # @cap.run_command(['u']) end it '#init from command line with sinatra' do @cap.run_command(['i:sinatra']) File.exist?('capucine.yaml').should be_true size = File.size('capucine.yaml') size.should_not == 0 FileUtils.rm_r 'capucine.yaml' end it '#init from command line with wrong template' do @cap.run_command(['i:sinatraaaaa']) File.exist?('capucine.yaml').should == false end it '#init from command line with distant template' do @cap.run_command(['i', 'http://capucine.dln.name/capucine.yaml']) File.exist?('capucine.yaml').should == true size = File.size('capucine.yaml') size.should_not == 0 FileUtils.rm_r 'capucine.yaml' end it '#new from command line' do @cap.run_command(['n']) cap = File.join @cap.settings.working_dir, 'capucine.yaml' sass = File.join @cap.settings.working_dir, 'public/css_generated/screen.css' @cap.settings.working_dir.should eq(File.join Dir.pwd, 'capucine') File.exist?(cap).should eq(true) File.exist?(sass).should eq(true) FileUtils.rm_r @cap.settings.working_dir end it '#new from command line with custom name' do @cap.run_command(['n', 'oh_my_god']) cap = File.join @cap.settings.working_dir, 'capucine.yaml' sass = File.join @cap.settings.working_dir, 'public/css_generated/screen.css' @cap.settings.working_dir.should eq(File.join Dir.pwd, 'oh_my_god') File.exist?(cap).should eq(true) File.exist?(sass).should eq(true) FileUtils.rm_r @cap.settings.working_dir end it '#new, set coffee, compile' do @cap.run_command(['n']) Dir.chdir('capucine') @cap.settings.conf['use_coffeescript'].should eq(false) @cap.run_command(['c', @config_user_coffee]) @cap.settings.user_config_file.should_not eq(nil) @cap.settings.conf['use_coffeescript'].should eq(true) coffee = File.expand_path(File.join @cap.settings.working_dir, 'public/js_generated/app.js') coffee2 = File.expand_path(File.join @cap.settings.working_dir, 'public/js_generated/app.min.js') File.exist?(coffee).should eq(true) File.exist?(coffee2).should eq(true) FileUtils.rm_r @cap.settings.working_dir Dir.chdir('..') end end