diff --git a/config/default.yml b/config/default.yml index cec31f04c..3537bc357 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,4 +1,7 @@ :ssh: :uname: hobo :pass: hobo - :host: localhost \ No newline at end of file + :host: localhost + +:vm: + :base: ~/.hobo/base/base.ovf \ No newline at end of file diff --git a/lib/hobo.rb b/lib/hobo.rb index 87a6afd66..f35781727 100644 --- a/lib/hobo.rb +++ b/lib/hobo.rb @@ -1,5 +1,5 @@ libdir = File.dirname(__FILE__) -$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) +$:.unshift(libdir) PROJECT_ROOT = File.join(libdir, '..') require 'ostruct' @@ -10,5 +10,6 @@ require 'hobo/env' require 'hobo/ssh' # TODO: Make this configurable -HOBO_LOGGER = Logger.new(STDOUT) +log_output = ENV['HOBO_ENV'] == 'test' ? nil : STDOUT +HOBO_LOGGER = Logger.new(log_output) Hobo::Env.load_config diff --git a/lib/hobo/env.rb b/lib/hobo/env.rb index c55f259e7..36c8b95d0 100644 --- a/lib/hobo/env.rb +++ b/lib/hobo/env.rb @@ -25,6 +25,8 @@ module Hobo def load_config ensure_directories ensure_files + + HOBO_LOGGER.info "Loading config from #{CONFIG.keys.first}" parsed = block_given? ? yield(CONFIG.keys.first) : YAML.load_file(CONFIG.keys.first) Hobo.config!(parsed) end diff --git a/test/hobo/env_test.rb b/test/hobo/env_test.rb index 4bb2f915f..aaeea590c 100644 --- a/test/hobo/env_test.rb +++ b/test/hobo/env_test.rb @@ -47,15 +47,15 @@ class EnvTest < Test::Unit::TestCase @handler.expects(:ensure_files).once @handler.load_config do |file| assert_equal file, Hobo::Env::CONFIG.keys.first - HOBO_MOCK_CONFIG + hobo_mock_config end - assert_equal Hobo.config[:ssh], HOBO_MOCK_CONFIG[:ssh] + assert_equal Hobo.config[:ssh], hobo_mock_config[:ssh] end test "should default to haml load of the default, without a block" do - YAML.expects(:load_file).with(Hobo::Env::CONFIG.keys.first).returns(HOBO_MOCK_CONFIG) + YAML.expects(:load_file).with(Hobo::Env::CONFIG.keys.first).returns(hobo_mock_config) @handler.load_config - assert_equal Hobo.config[:ssh], HOBO_MOCK_CONFIG[:ssh] + assert_equal Hobo.config[:ssh], hobo_mock_config[:ssh] end end end diff --git a/test/hobo/ssh_test.rb b/test/hobo/ssh_test.rb index a7c8ea2a8..9d65c5861 100644 --- a/test/hobo/ssh_test.rb +++ b/test/hobo/ssh_test.rb @@ -9,7 +9,7 @@ class SshTest < Test::Unit::TestCase end test "should call exec with defaults when no options are supplied" do - ssh = HOBO_MOCK_CONFIG[:ssh] + ssh = hobo_mock_config[:ssh] Kernel.expects(:exec).with("#{@script} #{ssh[:uname]} #{ssh[:pass]} #{ssh[:host]} #{ssh[:port]}") Hobo::SSH.connect end diff --git a/test/test_helper.rb b/test/test_helper.rb index c00f7f5df..d288d4210 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,8 @@ ENVERR exit end +ENV['HOBO_ENV'] = 'test' + # ruby-debug, not necessary, but useful if we have it begin require 'ruby-debug' @@ -22,12 +24,15 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'hobo') require 'contest' require 'mocha' -HOBO_MOCK_CONFIG = -{ :ssh => - { - :uname => 'foo', - :pass => 'bar', - :host => 'baz', - :port => 'bak' - } -} +class Test::Unit::TestCase + def hobo_mock_config + { :ssh => + { + :uname => 'foo', + :pass => 'bar', + :host => 'baz', + :port => 'bak' + } + } + end +end \ No newline at end of file