Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 40 lines (30 sloc) 1.072 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
require 'test_helper'

module Tire

  class ResultsIntegrationTest < Test::Unit::TestCase
    include Test::Integration

    context "Query results" do

      should "allow easy access to returned documents" do
        q = 'title:one'
        s = Tire.search('articles-test') { query { string q } }
        assert_equal 'One', s.results.first.title
        assert_equal 'ruby', s.results.first.tags[0]
      end

      should "allow easy access to returned documents with limited fields" do
        q = 'title:one'
        s = Tire.search('articles-test') { query { string q }.fields :title }
        assert_equal 'One', s.results.first.title
        assert_nil s.results.first.tags
      end

      should "allow to retrieve multiple fields" do
        q = 'title:one'
        s = Tire.search('articles-test') do
          query { string q }
          fields 'title', 'tags'
        end
        assert_equal 'One', s.results.first.title
        assert_equal 'ruby', s.results.first.tags[0]
        assert_nil s.results.first.published_on
      end

    end

  end

end
Something went wrong with that request. Please try again.