Skip to content
Browse files

Extract file writing helpers

  • Loading branch information...
1 parent aa32fe0 commit 86d617fbc9b9c81db5fe5847b81b3026ceefb02a @matschaffer matschaffer committed Jun 8, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 test/support/integration_test.rb
View
10 test/support/integration_test.rb
@@ -47,8 +47,14 @@ def teardown
# Writes out the given node hash as a json file
def write_nodefile(node)
- File.open("nodes/#{server.public_ip_address}.json", 'w') do |f|
- f.print node.to_json
+ write_json_file("nodes/#{server.public_ip_address}.json", node)
+ end
+
+ # Writes out an object to the given file as JSON
+ def write_json_file(file, data)
+ FileUtils.mkpath(File.dirname(file))
+ File.open(file, 'w') do |f|
+ f.print data.to_json
end
end

0 comments on commit 86d617f

Please sign in to comment.
Something went wrong with that request. Please try again.