Sha256: 387b24432fa58d478451c260573d04b529bfc97dfb7ca5615936229675122801

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

require File.join(File.dirname(__FILE__), "..", "test_helper")

class WorklingDelta::WorkerTest < Test::Unit::TestCase
  context "a worker" do
    setup do
      @index_name = "the_delta_index"
      @document_id = 1

      @job = mock(Object)
      mock(ThinkingSphinx::Deltas::DeltaJob).new(@index_name) { @job }
      @job.perform
    end

    context "that doesn't receive a document id" do
      
      should "perform a TS delta job with the index name" do
        invoke_worker(:index_name => @index_name)
      end

      should "not perform a flag as deleted job if I don't pass a document id" do
        dont_allow(ThinkingSphinx::Deltas::FlagAsDeletedJob).new(
         anything, anything)
        
        invoke_worker(:index_name => @index_name)
      end

    end

    context "that receives a document id" do
      should "trigger a flag as deleted job if I pass a document id" do
        delete_job = mock(Object)
        mock(ThinkingSphinx::Deltas::FlagAsDeletedJob).new(
          @index_name, @document_id) { delete_job }
        delete_job.perform

        invoke_worker(:index_name => @index_name, :document_id => @document_id)
      end
    end
    
  end

  private
  def invoke_worker(options = {})
    WorklingDelta::Worker.new.index(options)
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
dpickett-workling_delta_indexer-0.1.0 test/workling_delta/worker_test.rb
dpickett-workling_delta_indexer-0.1.1 test/workling_delta/worker_test.rb
lostboy-workling_delta_indexer-0.1.1.1 test/workling_delta/worker_test.rb
workling_delta_indexer-0.1.2 test/workling_delta/worker_test.rb