From fa49eb37583e066d10a71555f318a72abb5189cc Mon Sep 17 00:00:00 2001 From: Lee Richmond Date: Tue, 8 Jan 2019 11:44:27 -0500 Subject: [PATCH] Make schema directory if it doesn't exist --- lib/graphiti/schema.rb | 1 + spec/schema_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/graphiti/schema.rb b/lib/graphiti/schema.rb index 93908463..0eb1e078 100644 --- a/lib/graphiti/schema.rb +++ b/lib/graphiti/schema.rb @@ -16,6 +16,7 @@ def self.generate!(resources = nil) errors = Graphiti::SchemaDiff.new(old, schema).compare return errors if errors.any? end + FileUtils.mkdir_p(Graphiti.config.schema_path.gsub('/schema.json', '')) File.write(Graphiti.config.schema_path, JSON.pretty_generate(schema)) [] end diff --git a/spec/schema_spec.rb b/spec/schema_spec.rb index 35c61770..51c8223f 100644 --- a/spec/schema_spec.rb +++ b/spec/schema_spec.rb @@ -670,6 +670,7 @@ def self.name;'Schema::CondoResource';end end before do + allow(FileUtils).to receive(:mkdir_p).with('/schema/path') allow(File).to receive(:write) allow(File).to receive(:read).with('/schema/path/schema.json') { old_schema } allow(File).to receive(:exists?)