简体   繁体   中英

rspec + elasticsearch test index

I use elasticsearch gem .

I have calculations, that are based on queries to ES and it's responses.

Is there a way to create a fake index for test purposes and direct all the queries to this one instead of a real ES?

Or, may be, there is more efficient way to test something, that is tightly connected to ES? I assume faking the index would slow down the test significantly, but did not think of anything better yet. Thanks!

Since elasticsearch uses http, you can use something like VCR to record the HTTP requests.

VCR records your requests the first time you run perform them. Subsequent requests won't hit the server. Instead, VCR returns the recorded response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM