persisted_uuid will be null unless the dotfile exists
This commit is contained in:
parent
e98e9eba24
commit
4fa88e6436
|
@ -37,8 +37,11 @@ module Hobo
|
|||
end
|
||||
|
||||
def load_uuid!
|
||||
# TODO check multiple lines after the first for information
|
||||
@@persisted_uuid = File.open(Hobo.config[:dotfile_name], 'r').first
|
||||
@@persisted_uuid = nil
|
||||
if File.exists?(Hobo.config[:dotfile_name])
|
||||
# TODO check multiple lines after the first for information
|
||||
@@persisted_uuid = File.open(Hobo.config[:dotfile_name], 'r').first
|
||||
end
|
||||
end
|
||||
|
||||
def persisted_uuid
|
||||
|
|
|
@ -60,12 +60,19 @@ class EnvTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
test "load! should load the config and set the persisted_uid" do
|
||||
dot_file_expectation
|
||||
config_file_expectation
|
||||
dot_file_expectation
|
||||
Hobo::Env.load!
|
||||
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
|
||||
File.expects(:exists?).at_least_once.returns(true)
|
||||
File.expects(:open).with('.hobo', 'r').returns(['foo'])
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue