aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/moco.rb
diff options
context:
space:
mode:
authorMike McQuaid2014-10-06 11:35:18 +0100
committerMike McQuaid2014-10-06 11:36:53 +0100
commitefe2711f7ba5780f0de4e18d65608704028104cd (patch)
tree355f3d3a57064405a5bbbdfa7f806f7717bee6e2 /Library/Formula/moco.rb
parent9febcb35fb8ff6d94731f6c786bd3cc6cb61d813 (diff)
downloadhomebrew-efe2711f7ba5780f0de4e18d65608704028104cd.tar.bz2
moco: cleanup test.
Diffstat (limited to 'Library/Formula/moco.rb')
-rw-r--r--Library/Formula/moco.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/Library/Formula/moco.rb b/Library/Formula/moco.rb
index 093b4c5c2..913d44cbd 100644
--- a/Library/Formula/moco.rb
+++ b/Library/Formula/moco.rb
@@ -1,5 +1,4 @@
require "formula"
-require 'net/http'
class Moco < Formula
homepage "https://github.com/dreamhead/moco"
@@ -12,8 +11,9 @@ class Moco < Formula
end
test do
- port=12306
- (testpath/'config.json').write <<-TEST_SCRIPT.undent
+ require "net/http"
+
+ (testpath/"config.json").write <<-EOS.undent
[
{
"response" :
@@ -22,15 +22,18 @@ class Moco < Formula
}
}
]
- 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."
+ EOS
+
+ port = 12306
+ thread = Thread.new do
+ system bin/"moco", "start", "-p", port, "-c", testpath/"config.json"
end
- startMoco.exit
+
+ # Wait for Moco to start.
+ sleep 5
+
+ response = Net::HTTP.get URI "http://localhost:#{port}"
+ assert_equal "Hello, Moco", response
+ thread.exit
end
end