homebrew-core/Formula/moco.rb

50 lines
1.3 KiB
Ruby

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.2.0/moco-runner-1.2.0-standalone.jar"
sha256 "7d5bcbed4cf39a960fb523d8b4c073579c3cdca1b3971901be751b7afc9f37fe"
license "MIT"
livecheck do
url "https://search.maven.org/remotecontent?filepath=com/github/dreamhead/moco-runner/"
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "acd799b20fe83f3183af8c10c39cb7b78e43f0366c1137006f869649577f1765"
end
depends_on "openjdk"
def install
libexec.install "moco-runner-#{version}-standalone.jar"
bin.write_jar_script libexec/"moco-runner-#{version}-standalone.jar", "moco"
end
test do
(testpath/"config.json").write <<~EOS
[
{
"response" :
{
"text" : "Hello, Moco"
}
}
]
EOS
port = free_port
begin
pid = fork do
exec "#{bin}/moco http -p #{port} -c #{testpath}/config.json"
end
sleep 10
assert_match "Hello, Moco", shell_output("curl -s http://127.0.0.1:#{port}")
ensure
Process.kill "SIGTERM", pid
Process.wait pid
end
end
end