Sha256: c177c80926a9403b19f49d7703cda5e2ce147832c9538382bcc9eca42606e63d

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

module Foreground
  describe CLI do
    before do
      Daemon.stub(:run)
      @cmd = 'foreground_sample_daemon --with "some arguments"'
      @argv = ['--pid_file', '/tmp/foreground_sample_daemon.pid', '--command', @cmd]
      @cli = CLI.new
    end

    describe '.run' do
      it 'should run a new instance' do
        cli = mock('cli')
        cli.should_receive(:run).with(@argv)
        CLI.should_receive(:new).and_return(cli)
        CLI.run(@argv)
      end
    end

    describe '#run' do
      it 'should parse argv' do
        @cli.should_receive(:parse_options).with(@argv).and_return(@argv)
        @cli.run(@argv)
      end

      it 'should make the config globally available' do
        @cli.run(@argv)
        Foreground.config.should eql(@cli.config)
      end

      it 'should run the daemon' do
        Daemon.should_receive(:run).with(@cmd, '/tmp/foreground_sample_daemon.pid')
        @cli.run(@argv)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreground-0.1.0 spec/foreground/cli_spec.rb