Skip to content

Instantly share code, notes, and snippets.

@evanwhalen
Created April 18, 2013 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanwhalen/5413605 to your computer and use it in GitHub Desktop.
Save evanwhalen/5413605 to your computer and use it in GitHub Desktop.
Elasticsearch tire rspec filters
# Prevent calls from going out to elasticsearch unless we specify the example is an elasticsearch test
config.before :each do
unless (example.metadata[:elasticsearch] && example.metadata[:elasticsearch] == true)
stub_request(:any, %r|\Ahttp://.*9200.*|).to_return(:status => 200, :body => "{}")
end
end
config.before :each, elasticsearch: true do
[Product, User].each do |klass|
klass.index.delete
klass.create_elasticsearch_index
end
Resque.inline = true
end
config.after :each, elasticsearch: true do
[Product, User].each do |klass|
klass.index.delete
end
Resque.inline = false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment