Sha256: f76db41ae118d33f3cbe287918df24538dca9726adb7766e43b27a1649bc7137

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe "Sphinx Updates", :live => true do
  before :each do
    @client = Riddle::Client.new("localhost", 9313)
  end
  
  it "should update a single record appropriately" do
    # check existing birthday
    result = @client.query("Ellie K Ford")
    result[:matches].should_not be_empty
    result[:matches].length.should == 1
    ellie = result[:matches].first
    ellie[:attributes]["birthday"].should == Time.local(1970, 1, 23).to_i
    
    # make Ellie younger by 6 years
    @client.update("people", ["birthday"], {ellie[:doc] => [Time.local(1976, 1, 23).to_i]})
    
    # check attribute's value
    result = @client.query("Ellie K Ford")
    result[:matches].should_not be_empty
    result[:matches].length.should == 1
    ellie = result[:matches].first
    ellie[:attributes]["birthday"].should == Time.local(1976, 1, 23).to_i
  end
  
  it "should update multiple records appropriately" do
    result = @client.query("Steele")
    pairs = {}
    result[:matches].each do |match|
      pairs[match[:doc]] = [match[:attributes]["birthday"] + (365*24*60*60)]
    end
    
    @client.update "people", ["birthday"], pairs
    
    result = @client.query("Steele")
    result[:matches].each do |match|
      match[:attributes]["birthday"].should == pairs[match[:doc]].first
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
riddle-2.1.0 spec/functional/update_spec.rb
riddle-2.0.0 spec/functional/update_spec.rb
riddle-1.5.12 spec/functional/update_spec.rb
riddle-1.5.11 spec/functional/update_spec.rb
riddle-1.5.10 spec/functional/update_spec.rb
riddle-1.5.9 spec/functional/update_spec.rb
riddle-1.5.8 spec/functional/update_spec.rb
riddle-1.5.7 spec/functional/update_spec.rb
riddle-1.5.6 spec/functional/update_spec.rb
riddle-1.5.5 spec/functional/update_spec.rb
riddle-1.5.4 spec/functional/update_spec.rb
riddle-1.5.3 spec/functional/update_spec.rb
riddle-1.5.2 spec/functional/update_spec.rb
riddle-1.5.1 spec/functional/update_spec.rb
riddle-1.5.0 spec/functional/update_spec.rb