test/test_daemon.rb in rubydns-0.7.3 vs test/test_daemon.rb in rubydns-0.8.0
- old
+ new
@@ -18,25 +18,24 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-require 'helper'
-require 'pathname'
+require 'minitest/autorun'
require 'rubydns'
-require 'rubydns/resolver'
-require 'rexec'
-require 'rexec/daemon'
+require 'process/daemon'
-class BasicTestServer < RExec::Daemon::Base
+class BasicTestServer < Process::Daemon
SERVER_PORTS = [[:udp, '127.0.0.1', 5350], [:tcp, '127.0.0.1', 5350]]
@@base_directory = File.dirname(__FILE__)
- def self.run
+ IN = Resolv::DNS::Resource::IN
+
+ def startup
# Start the RubyDNS server
RubyDNS::run_server(:listen => SERVER_PORTS) do
match("test.local", IN::A) do |transaction|
transaction.respond!("192.168.1.1")
end
@@ -51,23 +50,23 @@
end
end
end
end
-class DaemonTest < Test::Unit::TestCase
+class DaemonTest < MiniTest::Test
def setup
- $stderr.puts "Starting test server..."
+ BasicTestServer.controller output: File.open("/dev/null", "w")
+
BasicTestServer.start
end
def teardown
- $stderr.puts "Stoping test server..."
BasicTestServer.stop
end
def test_basic_dns
- assert_equal :running, RExec::Daemon::ProcessFile.status(BasicTestServer)
+ assert_equal :running, BasicTestServer.status
EventMachine.run do
resolver = RubyDNS::Resolver.new(BasicTestServer::SERVER_PORTS)
resolver.query("test.local") do |response|
@@ -80,10 +79,10 @@
end
end
end
def test_pattern_matching
- assert_equal :running, RExec::Daemon::ProcessFile.status(BasicTestServer)
+ assert_equal :running, BasicTestServer.status
EventMachine.run do
resolver = RubyDNS::Resolver.new(BasicTestServer::SERVER_PORTS)
resolver.query("foobar") do |response|