test/results_test.rb in inquisitio-1.2.2 vs test/results_test.rb in inquisitio-1.2.3
- old
+ new
@@ -4,10 +4,11 @@
class ResultsTest < Minitest::Test
def setup
super
@search_endpoint = 'http://my.search-endpoint.com'
Inquisitio.config.search_endpoint = @search_endpoint
+ Inquisitio.config.api_version = nil
@result_1 = {'data' => {'id' => ['1'], 'title' => ["Foobar"], 'type' => ["Cat"]}}
@result_2 = {'data' => {'id' => ['2'], 'title' => ["Foobar"], 'type' => ["Cat"]}}
@result_3 = {'data' => {'id' => ['20'], 'title' => ["Foobar2"], 'type' => ["Module_Dog"]}}
@expected_results = [@result_1, @result_2, @result_3]
@start = 5
@@ -30,13 +31,24 @@
searcher = Searcher.where("star_wars")
searcher.search
assert_equal @found, searcher.total_entries
end
- def test_should_return_time_taken
+ def test_should_return_time_taken_for_2011
searcher = Searcher.where("star_wars")
searcher.search
assert_equal 3, searcher.time_ms
+ end
+
+ def test_should_return_time_taken_for_2013
+ Inquisitio.config.api_version = '2013-01-01'
+ body = "{\"status\": {\"rid\" : \"u9aP4eYo8gIK0csK\", \"time-ms\": 4}, \"hits\" : {\"#{@found}\": 33, \"#{@start}\": 0, \"hit\":#{@expected_results.to_json} }}"
+ Excon.stubs.clear
+ Excon.stub({}, {body: body, status: 200})
+
+ searcher = Searcher.where("star_wars")
+ searcher.search
+ assert_equal 4, searcher.time_ms
end
def test_total_entries_should_proxy
searcher = Searcher.where("star_wars")
searcher.search