Skip to content

Instantly share code, notes, and snippets.

@cpetschnig
Created July 21, 2010 08:25
Show Gist options
  • Save cpetschnig/484222 to your computer and use it in GitHub Desktop.
Save cpetschnig/484222 to your computer and use it in GitHub Desktop.
From e35a6eaef85051163204a1ba5c7fa4facdad6420 Mon Sep 17 00:00:00 2001
From: Christoph Petschnig <[email protected]>
Date: Wed, 21 Jul 2010 09:52:27 +0200
Subject: [PATCH 1/2] Added 'rake test'
---
Rakefile | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Rakefile b/Rakefile
index b9c08fa..343ac62 100644
--- a/Rakefile
+++ b/Rakefile
@@ -21,4 +21,11 @@ rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install jeweler"
end
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
+end
+
# vim: syntax=Ruby
--
1.7.1
From b83abece548d59b518092deab20e14c38e36c9f3 Mon Sep 17 00:00:00 2001
From: Christoph Petschnig <[email protected]>
Date: Wed, 21 Jul 2010 10:16:40 +0200
Subject: [PATCH 2/2] Fix: callback daemon.stop now gets invoked
---
lib/daemon_spawn.rb | 1 +
test/daemon_spawn_test.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/daemon_spawn.rb b/lib/daemon_spawn.rb
index 2e3d628..946ec67 100644
--- a/lib/daemon_spawn.rb
+++ b/lib/daemon_spawn.rb
@@ -48,6 +48,7 @@ module DaemonSpawn
def self.stop(daemon) #:nodoc:
if pid = daemon.pid
+ daemon.stop
FileUtils.rm(daemon.pid_file)
Process.kill("TERM", pid)
begin
diff --git a/test/daemon_spawn_test.rb b/test/daemon_spawn_test.rb
index 14eccea..d811647 100644
--- a/test/daemon_spawn_test.rb
+++ b/test/daemon_spawn_test.rb
@@ -30,7 +30,7 @@ class DaemonSpawnTest < Test::Unit::TestCase
begin
with_socket
ensure
- assert_match(//, `./echo_server.rb stop`)
+ assert_match(/^Stopping EchoServer.../, echo_server('stop'))
assert_raises(Errno::ECONNREFUSED) { TCPSocket.new('localhost', 5150) }
end
end
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment