class Moco < Formula desc "Stub server with Maven, Gradle, Scala, and shell integration" homepage "https://github.com/dreamhead/moco" url "https://search.maven.org/remotecontent?filepath=com/github/dreamhead/moco-runner/1.0.0/moco-runner-1.0.0-standalone.jar" sha256 "32e5490e19282c4ef0e88933b1638d506f3eb76f8dc9e85f311fb98c068059f5" bottle :unneeded def install libexec.install "moco-runner-#{version}-standalone.jar" bin.write_jar_script libexec/"moco-runner-#{version}-standalone.jar", "moco" end test do require "net/http" (testpath/"config.json").write <<~EOS [ { "response" : { "text" : "Hello, Moco" } } ] EOS port = 12306 thread = Thread.new do system bin/"moco", "http", "-p", port, "-c", testpath/"config.json" end # Wait for Moco to start. sleep 5 response = Net::HTTP.get URI "http://localhost:#{port}" assert_equal "Hello, Moco", response thread.exit end end