homebrew-core/Formula/moco.rb
2017-12-25 00:42:13 -08:00

40 lines
1 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/0.12.0/moco-runner-0.12.0-standalone.jar"
sha256 "436ccc154d0386bbb8924383cae2cf541b3eebdf23ad1709eae887632f39b8f5"
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