test/searcher_test.rb in inquisitio-0.0.13 vs test/searcher_test.rb in inquisitio-0.1.0

- old
+ new

@@ -4,13 +4,13 @@ class SearcherTest < Minitest::Test def setup super @search_endpoint = 'http://my.search-endpoint.com' Inquisitio.config.search_endpoint = @search_endpoint - @result_1 = {'med_id' => 1, 'title' => "Foobar", 'med_type' => "Cat"} - @result_2 = {'med_id' => 2, 'title' => "Foobar", 'med_type' => "Cat"} - @result_3 = {'med_id' => 20, 'title' => "Foobar2", 'med_type' => "Module_Dog"} + @result_1 = {'data' => {'med_id' => ['1'], 'title' => ["Foobar"], 'med_type' => ["Cat"]}} + @result_2 = {'data' => {'med_id' => ['2'], 'title' => ["Foobar"], 'med_type' => ["Cat"]}} + @result_3 = {'data' => {'med_id' => ['20'], 'title' => ["Foobar2"], 'med_type' => ["Module_Dog"]}} @expected_results = [@result_1, @result_2, @result_3] @body = <<-EOS {"rank":"-text_relevance","match-expr":"(label 'star wars')","hits":{"found":2,"start":0,"hit":#{@expected_results.to_json}},"info":{"rid":"9d3b24b0e3399866dd8d376a7b1e0f6e930d55830b33a474bfac11146e9ca1b3b8adf0141a93ecee","time-ms":3,"cpu-time-ms":0}} EOS @@ -254,22 +254,22 @@ searcher.send(:search_url) end def test_should_return_ids searcher = Searcher.where('Star Wars') - assert_equal @expected_results.map{|r|r['med_id']}, searcher.ids + assert_equal [1,2,20], searcher.ids end - def test_should_return_ids + def test_should_return_records Object.const_set :Cat, Object.new Module.const_set :Dog, Object.new res1 = "Foobar" res2 = 123 res3 = true - Cat.expects(:where).with(id: [1,2]).returns([res1, res2]) - Module::Dog.expects(:where).with(id: [20]).returns([res3]) + Cat.expects(:where).with(id: ['1','2']).returns([res1, res2]) + Module::Dog.expects(:where).with(id: ['20']).returns([res3]) searcher = Searcher.new searcher.instance_variable_set("@results", []) assert_equal [res1, res2, res3], Searcher.records end