Sha256: 0f3089806300603fc284f6f671156fedfd83a32c90b98a58042872c56997cb68

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

RSpec.describe ThinkingSphinx::Interfaces::Daemon do
  let(:configuration) { double 'configuration', :controller => controller }
  let(:controller)    { double 'controller', :running? => false }
  let(:stream)        { double 'stream', :puts => true }
  let(:interface)     {
    ThinkingSphinx::Interfaces::Daemon.new(configuration, {}, stream)
  }

  describe '#start' do
    let(:command) { double 'command', :call => true }

    before :each do
      stub_const 'ThinkingSphinx::Commands::StartDetached', command
    end

    it "starts the daemon" do
      expect(command).to receive(:call)

      interface.start
    end

    it "raises an error if the daemon is already running" do
      allow(controller).to receive_messages :running? => true

      expect {
        interface.start
      }.to raise_error(ThinkingSphinx::SphinxAlreadyRunning)
    end
  end

  describe '#status' do
    it "reports when the daemon is running" do
      allow(controller).to receive_messages :running? => true

      expect(stream).to receive(:puts).
        with('The Sphinx daemon searchd is currently running.')

      interface.status
    end

    it "reports when the daemon is not running" do
      allow(controller).to receive_messages :running? => false

      expect(stream).to receive(:puts).
        with('The Sphinx daemon searchd is not currently running.')

      interface.status
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-3.4.1 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-3.4.0 spec/thinking_sphinx/interfaces/daemon_spec.rb