I use ElasticSearch on the homepage of my site. In my acceptance tests, when a user logs in, he's redirected to the homepage.
But using ES in a test is expensive (need to create and delete the index), so I don't want to have to do that every time a user goes through the homepage.
I would like to do the actual ES search only when the test has some metadata:
config.before(:each) do
if example.metadata[:elastic]
Model.create_elasticsearch_index
end
end
scenario "Results should be ordered by distance", :elastic do
# tests...
end
So I would need to "mock" the search and not use ES when the test does no have the :elastic metadata.
What would be a good way to achieve that?