module Elasticsearch::Embedded::RSpec

Public Class Methods

configure() click to toggle source

Default config method, configure RSpec with :elasticsearch filter only. Equivalent to .configure_with(:elasticsearch)

# File lib/elasticsearch/embedded/rspec_configuration.rb, line 62
def configure
  configure_with(elasticsearch: true)
end
configure_with(*meta) click to toggle source

Configure rspec for usage with ES cluster

# File lib/elasticsearch/embedded/rspec_configuration.rb, line 40
def configure_with(*meta)
  # assign default value to tags
  ::RSpec.configure do |config|

    # Include helpers only in tagged specs
    config.include ElasticSearchHelpers, *meta

    # Before hook, starts the cluster
    config.before(:each, *meta) do
      ElasticSearchHelpers.memoized_cluster.ensure_started!
      ElasticSearchHelpers.memoized_cluster.delete_all_indices!
    end

    # After suite hook, stop the cluster
    config.after(:suite) do
      ElasticSearchHelpers.memoized_cluster.stop if ElasticSearchHelpers.memoized_cluster.running?
    end
  end
end