Skip to content

Instantly share code, notes, and snippets.

@rowanoulton
Last active August 10, 2018 06:22
Show Gist options
  • Save rowanoulton/fbf35e0e69097a0a502a to your computer and use it in GitHub Desktop.
Save rowanoulton/fbf35e0e69097a0a502a to your computer and use it in GitHub Desktop.
# spec/spec_helper.rb
require 'elasticsearch/extensions/test/cluster'
RSpec.configure do |config|
# Start an in-memory cluster for Elasticsearch as needed
config.before :all, elasticsearch: true do
Elasticsearch::Extensions::Test::Cluster.start(port: 9250, nodes: 1, timeout: 120) unless Elasticsearch::Extensions::Test::Cluster.running?(on: 9250)
end
# Stop elasticsearch cluster after test run
config.after :suite do
Elasticsearch::Extensions::Test::Cluster.stop(port: 9250, nodes: 1) if Elasticsearch::Extensions::Test::Cluster.running?(on: 9250)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment