Sha256: 1f3546a18e9d445dc3d45afa1d5fbb1dd9adeca61e8fe98060775467f21740f9

Contents?: true

Size: 1.36 KB

Versions: 17

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ThinkingSphinx::Commands::Merge do
  let(:command)       { ThinkingSphinx::Commands::Merge.new(
    configuration, {:core_index => core_index, :delta_index => delta_index,
      :filters => {:sphinx_deleted => 0}}, stream
  ) }
  let(:configuration) { double "configuration", :controller => controller }
  let(:stream)        { double :puts => nil }
  let(:controller)    { double "controller", :merge => nil }
  let(:core_index)    { double "index", :path => "index_a_core",
    :name => "index_a_core" }
  let(:delta_index)   { double "index", :path => "index_a_delta",
    :name => "index_a_delta" }

  before :each do
    allow(File).to receive(:exist?).and_return(true)
  end

  it "merges core/delta pairs" do
    expect(controller).to receive(:merge).with(
      "index_a_core",
      "index_a_delta",
      :filters => {:sphinx_deleted => 0},
      :verbose => nil
    )

    command.call
  end

  it "does not merge if just the core does not exist" do
    allow(File).to receive(:exist?).with("index_a_core.spi").and_return(false)

    expect(controller).to_not receive(:merge)

    command.call
  end

  it "does not merge if just the delta does not exist" do
    allow(File).to receive(:exist?).with("index_a_delta.spi").and_return(false)

    expect(controller).to_not receive(:merge)

    command.call
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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