require "language/node" class Newman < Formula desc "Command-line collection runner for Postman" homepage "https://www.getpostman.com" url "https://registry.npmjs.org/newman/-/newman-4.5.5.tgz" sha256 "21209b816385c04dd3634879a21149ed75f0da0b333c4fd2861e15684653307b" bottle do cellar :any_skip_relocation sha256 "f034c1ff83166e693704081cbb8bc529e649b27eeb8197967f94812ad9468413" => :mojave sha256 "f305286674687aca061c2d9f5a6e4ac1df2bf2dc0022ba7357ba111df0784e33" => :high_sierra end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do path = testpath/"test-collection.json" path.write <<~EOS { "info": { "_postman_id": "db95eac2-6e1c-48c0-8c3a-f83c5341d4dd", "name": "Homebrew", "description": "Homebrew formula test", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "httpbin-get", "request": { "method": "GET", "header": [], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "https://httpbin.org/get", "protocol": "https", "host": [ "httpbin", "org" ], "path": [ "get" ] } }, "response": [] } ] } EOS assert_match /newman/, shell_output("#{bin}/newman run #{path}") assert_equal version.to_s, shell_output("#{bin}/newman --version").strip end end