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
|
end
|
||||||
|
|
||||||
def load_uuid!
|
def load_uuid!
|
||||||
# TODO check multiple lines after the first for information
|
@@persisted_uuid = nil
|
||||||
@@persisted_uuid = File.open(Hobo.config[:dotfile_name], 'r').first
|
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
|
end
|
||||||
|
|
||||||
def persisted_uuid
|
def persisted_uuid
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue