Sha256: 1a64b4d1066513209bc2d0863e4a8c8cc1a70e3404db7c211e6bc0fb13d4a6df
Contents?: true
Size: 1.2 KB
Versions: 4
Compression:
Stored size: 1.2 KB
Contents
require "ostruct" require "simplecov" require "active_hash" SimpleCov.start do add_filter "/spec/" end SimpleCov.minimum_coverage 95 require_relative '../lib/elastic_mapper' # A helper to delete, and recreate the # ElasticSearch index used for specs. # This code is borrowed from the stretcher specs. def reset_index ElasticMapper.index_name = "elastic_mapper_tests" index = ElasticMapper.index server = ElasticMapper.server index.delete rescue nil # ignore exceptions. server.refresh index.create({ :settings => { :number_of_shards => 1, :number_of_replicas => 0 } }) # Why do both? Doesn't hurt, and it fixes some races server.refresh index.refresh # Sometimes the index isn't instantly available (0..40).each do idx_metadata = server.cluster.request(:get, :state)[:metadata][:indices][index.name] i_state = idx_metadata[:state] break if i_state == 'open' if attempts_left < 1 raise "Bad index state! #{i_state}. Metadata: #{idx_metadata}" end sleep 0.1 end end # Index the model provided, # and refresh the index so that the # document can be searched. def index(model) model.index ElasticMapper.index.refresh end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
elastic_mapper-0.3.0 | spec/spec_helper.rb |
elastic_mapper-0.2.1 | spec/spec_helper.rb |
elastic_mapper-0.1.0 | spec/spec_helper.rb |
elastic_mapper-0.0.1 | spec/spec_helper.rb |