Permalink
Browse files

Add .gemspec and test

  • Loading branch information...
icy committed Jul 20, 2012
1 parent fb34180 commit 04bb841780133c52d38405ada4fc239dbd8880a1
Showing with 54 additions and 0 deletions.
  1. +9 −0 Rakefile
  2. 0 rolo.rb → bin/rolo
  3. +19 −0 rolo.gemspec
  4. +26 −0 test/test_rolo.rb
View
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+end
+
+desc "Run tests"
+task :default => :test
View
File renamed without changes.
View
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+# Purpose: Gem specification
+# Author : Anh K. Huynh
+# License: GPL2
+# Date : 2012 July 20th
+
+Gem::Specification.new do |s|
+ s.name = 'rolo'
+ s.version = '1.0.1'
+ s.date = '2012-07-20'
+ s.summary = "`rolo` prevents a program from running more than one copy at a time"
+ s.description = "Prevents a program from running more than one copy at a time"
+ s.authors = ["Anh K. Huynh"]
+ s.email = 'kyanh@viettug.org'
+ s.files = %w(README.md)
+ s.homepage = 'https://github.com/icy/rolo'
+ s.executables << "rolo"
+end
View
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+
+require 'rake/testtask'
+require 'test/unit'
+
+class RoloTest < Test::Unit::TestCase
+ @@rolo = File.join(File.dirname(__FILE__), "../bin/rolo")
+
+ def test_low_port
+ ret = %x{#{@@rolo} --port 123 sleep 100 2>&1}
+ assert_match /Permission denied/, ret
+ end
+
+ def test_no_command
+ ret = %x{#{@@rolo} --port 60000 2>&1}
+ assert_match /You must provide a command/, ret
+ end
+
+ def test_running
+ (pid = fork) ? Process.detach(pid) : exec("#{@@rolo} --port 60000 sleep 3 2>&1")
+ ret = %x{#{@@rolo} --port 60000 sleep 2 2>&1}
+ assert_match /your application running/, ret
+ begin Process.wait(pid) rescue nil ; end
+ sleep(3)
+ end
+end

0 comments on commit 04bb841

Please sign in to comment.