Sha256: 78c73b8e1cc66e437206ff0fe096b032b1efe85895861aeb23f181ec16d25236

Contents?: true

Size: 1.28 KB

Versions: 20

Compression:

Stored size: 1.28 KB

Contents

require 'spec/spec_helper'

describe "Sphinx Updates" do
  before :each do
    @client = Riddle::Client.new("localhost", 3313)
  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

20 entries across 20 versions & 3 rubygems

Version Path
freelancing-god-riddle-0.9.8.1371.1 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1371.2 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.1 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.2 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.3 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.4 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.5 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.7 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.8 spec/functional/update_spec.rb
freelancing-god-riddle-0.9.8.1533.9 spec/functional/update_spec.rb
riddle-0.9.8.1533.10 spec/functional/update_spec.rb
riddle-0.9.8.1112 spec/functional/update_spec.rb
riddle-0.9.8.1198.1 spec/functional/update_spec.rb
riddle-0.9.8.1198 spec/functional/update_spec.rb
riddle-0.9.8.1231.0 spec/functional/update_spec.rb
ultrasphinx-1.6.7 vendor/riddle/spec/functional/update_spec.rb
ultrasphinx-1.11 vendor/riddle/spec/functional/update_spec.rb
ultrasphinx-1.8 vendor/riddle/spec/functional/update_spec.rb
ultrasphinx-1.7 vendor/riddle/spec/functional/update_spec.rb
ultrasphinx-1.9 vendor/riddle/spec/functional/update_spec.rb