test refactor

This commit is contained in:
John Bender 2010-01-22 00:56:27 -08:00
parent 7cd249ec63
commit 62f7682f9b
1 changed files with 11 additions and 8 deletions

View File

@ -5,15 +5,18 @@ class EnvTest < Test::Unit::TestCase
context "Hobo environment handler" do context "Hobo environment handler" do
setup do setup do
@handler = Hobo::Env.new @handler = Hobo::Env.new
@ensure = Hobo::Env::ENSURE
end end
test "should check for all required directories" do test "should not create any directories if they exist" do
dir_expectations File.expects(:exists?).times(@ensure[:dirs].length).returns(true)
Dir.expects(:mkdir).never
@handler.ensure_directories @handler.ensure_directories
end end
test "should check for all required config files" do test "should not copy any files if they exist" do
file_expectations File.expects(:exists?).times(@ensure[:files].length).returns(true)
File.expects(:copy).never
@handler.ensure_files @handler.ensure_files
end end
@ -30,12 +33,12 @@ class EnvTest < Test::Unit::TestCase
end end
def dir_expectations def dir_expectations
File.expects(:exists?).times(Hobo::Env::ENSURE[:dirs].length).returns(false) File.expects(:exists?).times(@ensure[:dirs].length).returns(false)
Dir.expects(:mkdir).times(Hobo::Env::ENSURE[:dirs].length).returns nil Dir.expects(:mkdir).times(@ensure[:dirs].length).returns nil
end end
def file_expectations def file_expectations
File.expects(:exists?).times(Hobo::Env::ENSURE[:files].length).returns(false) File.expects(:exists?).times(@ensure[:files].length).returns(false)
File.expects(:copy).times(Hobo::Env::ENSURE[:files].length) File.expects(:copy).times(@ensure[:files].length)
end end
end end