A sample project that shows you how to test a ruby webapp that uses Elasticsearch.
- A simple webapp built with Sinatra that exposes two APIs:
GET /search
andPOST /index
GET /search?q=foo
will search your Elasticsearch instance for the stringfoo
POST /index
will add the JSON body of the request to your Elasticsearch instance
- Fork it
- Enable it
- Run it
The project comes with a working shippable.yml
file.
-
Get an Elasticsearch server running locally. If you have Docker, this is all you need to do:
docker run -d -p 9200 -p 9300 elasticsearch
-
Clone this repository and
bundle install
the first time to get all the gems. Then run the Sinatra webapp with this command:ELASTIC_SEARCH_PORT=9200 ELASTIC_SEARCH_HOST=localhost ruby app.rb
-
Run the tests with
bundle exec rake test