homebrew-core/Formula/wiremock-standalone.rb

37 lines
1.1 KiB
Ruby

class WiremockStandalone < Formula
desc "Simulator for HTTP-based APIs"
homepage "https://wiremock.org/docs/running-standalone/"
url "https://search.maven.org/remotecontent?filepath=com/github/tomakehurst/wiremock-jre8-standalone/2.33.2/wiremock-jre8-standalone-2.33.2.jar"
sha256 "4a424d645f4d8b4ac2df525dcb4def63f38c904c0d15cecb0a7320da6fe0efed"
license "Apache-2.0"
head "https://github.com/tomakehurst/wiremock.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "671ccf27e990892c749b3a75804493f30ff93a93e9b9508ffc9e556bb1f484aa"
end
depends_on "openjdk"
def install
libexec.install "wiremock-jre8-standalone-#{version}.jar"
bin.write_jar_script libexec/"wiremock-jre8-standalone-#{version}.jar", "wiremock"
end
test do
port = free_port
wiremock = fork do
exec "#{bin}/wiremock", "-port", port.to_s
end
loop do
Utils.popen_read("curl", "-s", "http://localhost:#{port}/__admin/", "-X", "GET")
break if $CHILD_STATUS.exitstatus.zero?
end
system "curl", "-s", "http://localhost:#{port}/__admin/shutdown", "-X", "POST"
Process.wait(wiremock)
end
end