Sha256: 9b0e74a0b1c9fcc85ec86360dfa26dca6e64e1bca43b54f776640deac337f57b
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe 'Client' do before(:all) do @index = Algolia::Index.new("friends") @index.delete rescue "not fatal" end it "should add a simple object" do @index.add_object!({ :name => "John Doe", :email => "john@doe.org" }) res = @index.search("john") res["hits"].length.should eq(1) end it "should add a set of objects" do @index.add_objects!([ { :name => "Another", :email => "another1@example.org" }, { :name => "Another", :email => "another2@example.org" } ]) res = @index.search("another") res["hits"].length.should eq(2) end it "should throw an exception if invalid argument" do expect { @index.add_object!([ {:name => "test"} ]) }.to raise_error(ArgumentError) expect { @index.add_objects!([ [ {:name => "test"} ] ]) }.to raise_error(ArgumentError) end it "should be thread safe" do threads = [] 64.times do t = Thread.new do 10.times do res = @index.search("john") res["hits"].length.should eq(1) end end threads << t end threads.each { |t| t.join } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
algoliasearch-1.1.5 | spec/client_spec.rb |
algoliasearch-1.1.4 | spec/client_spec.rb |
algoliasearch-1.1.3 | spec/client_spec.rb |