Sha256: a06ef938d75dc8d56abd811c50cefc6583603aa508efb9e3fd673ea2ac7ec4ad

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'optparse'

describe Trinidad::Extensions::DaemonServerExtension do
  subject { Trinidad::Extensions::DaemonServerExtension.new({}) }

  before(:each) do
    @tomcat = Trinidad::Tomcat::Tomcat.new
  end

  it "bypass the control to the daemon" do
    daemon = subject.configure(@tomcat)
    daemon.should_not be_nil
    daemon.should be_instance_of(org.jruby.trinidad.TrinidadDaemon)
  end

  it "uses a temporal directory to write the pid file by default" do
    daemon = subject.configure(@tomcat)
    daemon.pid_file.should =~ /trinidad.pid$/
  end

  it "can use a given pid file" do
    extension = Trinidad::Extensions::DaemonServerExtension.new(:pid_file => 'trinidad_pid.txt')
    daemon = extension.configure(@tomcat)
    daemon.pid_file.should =~ /trinidad_pid.txt$/
  end

  it "allows to specify a command line option to run the daemon" do
    extension = Trinidad::Extensions::DaemonOptionsExtension.new
    parser = OptionParser.new
    options = {}
    
    extension.configure(parser, options)
    parser.parse! '-d /tmp/trinidad.pid'.split

    options[:extensions].keys.should include(:daemon)
    options[:extensions][:daemon].should include(:pid_file)
    options[:extensions][:daemon][:pid_file].should == '/tmp/trinidad.pid'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trinidad_daemon_extension-0.1.0 spec/trinidad_daemon_extension_spec.rb