/
wiremock-standalone.rb
40 lines (31 loc) 路 1.22 KB
/
wiremock-standalone.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class WiremockStandalone < Formula
desc "Simulator for HTTP-based APIs"
homepage "https://wiremock.org/docs/running-standalone/"
url "https://search.maven.org/remotecontent?filepath=org/wiremock/wiremock-standalone/3.5.3/wiremock-standalone-3.5.3.jar"
sha256 "1c85a1b9a5b7ebf91db23f22643d00347436ea895446760bd6ae5f7105c71e3c"
license "Apache-2.0"
livecheck do
url "https://search.maven.org/remotecontent?filepath=org/wiremock/wiremock-standalone/maven-metadata.xml"
regex(%r{<version>v?(\d+(?:\.\d+)+)</version>}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "f7a07ced459b4a9e2a4cc7d55a930355b873478fe9af2811a3957460f8771686"
end
depends_on "openjdk"
def install
libexec.install "wiremock-standalone-#{version}.jar"
bin.write_jar_script libexec/"wiremock-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