Sha256: 1ae54689f4281392e6b13dc1219b2cd4f8d612753f850c1a061d2d8a1764a87e

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

require 'test_helper'

module Elasticsearch
  module Test
    class PercolateTest < ::Test::Unit::TestCase

      context "Percolate" do
        subject { FakeClient.new }

        should "require the :index argument" do
          assert_raise ArgumentError do
            subject.percolate :type => 'bar', :body => {}
          end
        end

        should "require the :body argument" do
          assert_raise ArgumentError do
            subject.percolate :index => 'bar'
          end
        end

        should "have default document type" do
          assert_nothing_raised do
            subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo/document/_percolate', url
            true
          end.returns(FakeResponse.new)

            subject.percolate :index => 'foo', :body => {}
          end
        end

        should "perform correct request" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'GET', method
            assert_equal 'foo/bar/_percolate', url
            assert_equal Hash.new, params
            assert_equal 'bar', body[:doc][:foo]
            true
          end.returns(FakeResponse.new)

          subject.percolate :index => 'foo', :type => 'bar', :body => { :doc => { :foo => 'bar' } }
        end

        should "URL-escape the parts" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo%5Ebar/bar%2Fbam/_percolate', url
            true
          end.returns(FakeResponse.new)

          subject.percolate :index => 'foo^bar', :type => 'bar/bam', :body => { :doc => { :foo => 'bar' } }
        end

      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
elasticsearch-api-0.4.11 test/unit/percolate_test.rb
elasticsearch-api-0.4.10 test/unit/percolate_test.rb
elasticsearch-api-0.4.9 test/unit/percolate_test.rb
elasticsearch-api-0.4.8 test/unit/percolate_test.rb
elasticsearch-api-0.4.7 test/unit/percolate_test.rb
elasticsearch-api-0.4.6 test/unit/percolate_test.rb
elasticsearch-api-0.4.5 test/unit/percolate_test.rb
elasticsearch-api-0.4.4 test/unit/percolate_test.rb
elasticsearch-api-0.4.3 test/unit/percolate_test.rb
elasticsearch-api-0.4.2 test/unit/percolate_test.rb
elasticsearch-api-0.4.1 test/unit/percolate_test.rb