spec/support/tmp_config.rb in brightbox-cli-1.2.2 vs spec/support/tmp_config.rb in brightbox-cli-1.3.0
- old
+ new
@@ -4,29 +4,25 @@
# This class encapsulates the pattern of creating a temporary configuration file
# from a String, easiliy referencing the directory to initialise a BBConfig and
# dispose of
#
class TmpConfig
-
+ attr_reader :path
# Creates a temporary directory and a "config" file within using the contents
# of a passed String.
#
# Recommended to use {#close} to delete
#
# @param [String] contents
#
def initialize(contents)
- @dir = Dir.mktmpdir
- @file = File.open(File.join(@dir, "config"), "w+")
+ @path = Dir.mktmpdir
+ @file = File.open(File.join(@path, "config"), "w+")
@file.write(contents)
@file.close
self
end
- def path
- @dir
- end
-
def close
- FileUtils.remove_entry_secure(@dir)
+ FileUtils.remove_entry_secure(path)
end
end