Commit d2c108e3 by andrew morton

Write JSON to disk

Fixes #1
parent e95d89af
......@@ -16,9 +16,9 @@ module RSpec
metadata = notification.example.metadata
return unless metadata[:swagger_object] == :response
metadata.each do |k, v|
puts "#{k}\t#{v}" if k.to_s.starts_with?("swagger")
end
# metadata.each do |k, v|
# puts "#{k}\t#{v}" if k.to_s.starts_with?("swagger")
# end
document = document_for(metadata[:swagger_document])
path_item = path_item_for(document, metadata[:swagger_path_item])
......@@ -31,7 +31,12 @@ module RSpec
end
def write_json(name, document)
puts JSON.pretty_generate(document)
root = ::RSpec.configuration.swagger_root
# It would be good to at least warn if the name includes some '../' that
# takes it out of root directory.
target = Pathname(name).expand_path(root)
target.dirname.mkpath
target.write(JSON.pretty_generate(document))
end
def document_for(doc_name = nil)
......
......@@ -197,6 +197,8 @@ module RSpec
module Resolver
def resolve_document metadata
# TODO: It's really inefficient to keep recreating this. It'd be nice
# if we could cache them some place.
name = metadata[:swagger_document]
Document.new(RSpec.configuration.swagger_docs[name])
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment