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?)