persisted_uuid will be null unless the dotfile exists

This commit is contained in:
John Bender 2010-01-29 23:48:05 -08:00
parent e98e9eba24
commit 4fa88e6436
2 changed files with 13 additions and 3 deletions

View File

@ -37,9 +37,12 @@ module Hobo
end end
def load_uuid! def load_uuid!
@@persisted_uuid = nil
if File.exists?(Hobo.config[:dotfile_name])
# TODO check multiple lines after the first for information # TODO check multiple lines after the first for information
@@persisted_uuid = File.open(Hobo.config[:dotfile_name], 'r').first @@persisted_uuid = File.open(Hobo.config[:dotfile_name], 'r').first
end end
end
def persisted_uuid def persisted_uuid
@@persisted_uuid @@persisted_uuid

View File

@ -60,12 +60,19 @@ class EnvTest < Test::Unit::TestCase
end end
test "load! should load the config and set the persisted_uid" do test "load! should load the config and set the persisted_uid" do
dot_file_expectation
config_file_expectation config_file_expectation
dot_file_expectation
Hobo::Env.load! Hobo::Env.load!
end end
test "when no dotfile exists uuid should be nil" do
Hobo.config! hobo_mock_config.merge(:dotfile_name => 'unpossiblyunpossiblfilename')
Hobo::Env.load_uuid!
assert_equal Hobo::Env.persisted_uuid, nil
end
def dot_file_expectation def dot_file_expectation
File.expects(:exists?).at_least_once.returns(true)
File.expects(:open).with('.hobo', 'r').returns(['foo']) File.expects(:open).with('.hobo', 'r').returns(['foo'])
end end