aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorHuang YunKun2014-09-28 09:30:19 +0800
committerMike McQuaid2014-10-06 11:36:00 +0100
commit9febcb35fb8ff6d94731f6c786bd3cc6cb61d813 (patch)
tree81f765f604b93d4ac3cdc9122503f77daa07ba34 /Library
parentb8d8806b35c1a1eae0729ca11dee0e445a940bdb (diff)
downloadhomebrew-9febcb35fb8ff6d94731f6c786bd3cc6cb61d813.tar.bz2
moco 0.9.2 (new formula)
Moco is an easy setup stub framework. More information can found in [https://github.com/dreamhead/moco](https://github.com/dreamhead/moco). Integration, especially based on HTTP protocol, e.g. web service, REST etc, is wildly used in most of our development. Moco can do it by provider a quick and fake server to help development.
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/moco.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/Library/Formula/moco.rb b/Library/Formula/moco.rb
new file mode 100644
index 000000000..093b4c5c2
--- /dev/null
+++ b/Library/Formula/moco.rb
@@ -0,0 +1,36 @@
+require "formula"
+require 'net/http'
+
+class Moco < Formula
+ homepage "https://github.com/dreamhead/moco"
+ url "http://central.maven.org/maven2/com/github/dreamhead/moco-runner/0.9.2/moco-runner-0.9.2-standalone.jar"
+ sha1 "a21445d7b275c48874ed7756477ade74de299e17"
+
+ def install
+ libexec.install "moco-runner-0.9.2-standalone.jar"
+ bin.write_jar_script libexec/"moco-runner-0.9.2-standalone.jar", "moco"
+ end
+
+ test do
+ port=12306
+ (testpath/'config.json').write <<-TEST_SCRIPT.undent
+ [
+ {
+ "response" :
+ {
+ "text" : "Hello, Moco"
+ }
+ }
+ ]
+ TEST_SCRIPT
+ startMoco=Thread.new do
+ system(bin/"moco","start","-p", port,"-c",(testpath/'config.json'))
+ end
+ sleep 5 #wait moco start
+ actualResponse=Net::HTTP.get(URI('http://localhost:'+port.to_s))
+ if(actualResponse!='Hello, Moco')
+ onoe "Error! The response is not right."
+ end
+ startMoco.exit
+ end
+end