From 84b4f8e681dff3dd8bcfe98365b405971fe1af53 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 12 Nov 2016 04:35:43 -0800 Subject: [PATCH] generate-json-schema 2.3.1 simplify test Closes #5300. Signed-off-by: ilovezfs --- Formula/generate-json-schema.rb | 83 ++------------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/Formula/generate-json-schema.rb b/Formula/generate-json-schema.rb index 6ca6be98ba..2f030ea92b 100644 --- a/Formula/generate-json-schema.rb +++ b/Formula/generate-json-schema.rb @@ -3,9 +3,8 @@ require "language/node" class GenerateJsonSchema < Formula desc "Generate a JSON Schema from Sample JSON" homepage "https://github.com/Nijikokun/generate-schema" - url "https://registry.npmjs.org/generate-schema/-/generate-schema-2.1.1.tgz" - sha256 "8f30beb978627b39831eaabf27df9df6e075b0bcc27e6543fab7582f3f30857d" - + url "https://registry.npmjs.org/generate-schema/-/generate-schema-2.3.1.tgz" + sha256 "c73926a44ebdf7f732f531624c012d667479b949378148607527fecb36044254" head "https://github.com/Nijikokun/generate-schema.git" bottle do @@ -25,8 +24,6 @@ class GenerateJsonSchema < Formula end test do - require "open3" - input = <<-EOS.undent { "id": 2, @@ -44,80 +41,6 @@ class GenerateJsonSchema < Formula } } EOS - - output = <<-EOS.undent.chomp - Welcome to Generate Schema 2.1.1 - - Mode: json - - * Example Usage: - > {a:'b'} - { a: { type: 'string' } } - - To quit type: exit - - > { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "id": { - "type": "number" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number" - }, - "tags": { - "type": "array", - "items": { - "type": "string" - } - }, - "dimensions": { - "type": "object", - "properties": { - "length": { - "type": "number" - }, - "width": { - "type": "number" - }, - "height": { - "type": "number" - } - } - }, - "warehouseLocation": { - "type": "object", - "properties": { - "latitude": { - "type": "number" - }, - "longitude": { - "type": "number" - } - } - } - } - } - > - EOS - - # As of v2.1.1, there is a bug when passing in a filename as an argument - # The following commented out test will fail until this bug is fixed. - # ("#{testpath}/test.json").write(input) - # system "#{bin}/generate-schema", "#{testpath}/test.json" - - # Until it is fixed, STDIN can be used as a workaround - Open3.popen3("#{bin}/generate-schema") do |stdin, stdout, _| - stdin.write(input) - stdin.close - # Program leaks spaces at the end of lines. This line cleans them up - # so they don't cause the assert below to erroneously fail. - result = stdout.map(&:rstrip).join("\n") - assert_equal output, result - end + assert_match "schema.org", pipe_output("#{bin}/generate-schema", input, 0) end end