Sha256: c719c3efe149dead26662c2cc385d34f403faa5ab65ccb2d28530002709e71c3

Contents?: true

Size: 1.61 KB

Versions: 17

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ThinkingSphinx::Interfaces::Daemon do
  let(:configuration) { double 'configuration' }
  let(:stream)        { double 'stream', :puts => true }
  let(:commander)     { double :call => nil }
  let(:interface)     {
    ThinkingSphinx::Interfaces::Daemon.new(configuration, {}, stream)
  }

  before :each do
    stub_const 'ThinkingSphinx::Commander', commander

    allow(commander).to receive(:call).
      with(:running, configuration, {}, stream).and_return(false)
  end

  describe '#start' do
    it "starts the daemon" do
      expect(commander).to receive(:call).with(
        :start_detached, configuration, {}, stream
      )

      interface.start
    end

    it "raises an error if the daemon is already running" do
      allow(commander).to receive(:call).
        with(:running, configuration, {}, stream).and_return(true)

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

  describe '#status' do
    it "reports when the daemon is running" do
      allow(commander).to receive(:call).
        with(:running, configuration, {}, stream).and_return(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(commander).to receive(:call).
        with(:running, configuration, {}, stream).and_return(false)

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

      interface.status
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.5.1 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.5.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.4.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.3.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.2.1 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.2.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.1.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-5.0.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.4.1 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.4.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.3.2 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.3.1 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.3.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.2.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.1.0 spec/thinking_sphinx/interfaces/daemon_spec.rb
thinking-sphinx-4.0.0 spec/thinking_sphinx/interfaces/daemon_spec.rb