Sha256: 68cdf7b7de3201aced82b63c0614c3197dd4a489e81ae1827b5ddfbead9d6c2c

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

require 'jbuilder'
require 'jsonify'

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

      context "JBuilder" do
        subject { FakeClient.new }

        should "build a JSON" do
          subject.expects(:perform_request).with do |method, url, params, body|
            json = MultiJson.load(body)

            assert_instance_of String, body
            assert_equal       'test', json['query']['match']['title']['query']
            true
          end.returns(FakeResponse.new)

          json = Jbuilder.encode do |json|
                   json.query do
                     json.match do
                       json.title do
                         json.query    'test'
                       end
                     end
                   end
                 end

          subject.search :body => json
        end
      end

      context "Jsonify" do
        subject { FakeClient.new }

        should "build a JSON" do
          subject.expects(:perform_request).with do |method, url, params, body|
            json = MultiJson.load(body)

            assert_instance_of String, body
            assert_equal       'test', json['query']['match']['title']['query']
            true
          end.returns(FakeResponse.new)

          json = Jsonify::Builder.compile do |json|
                   json.query do
                     json.match do
                       json.title do
                         json.query    'test'
                       end
                     end
                   end
                 end

          subject.search :body => json
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
elasticsearch-api-0.4.6 test/unit/json_builders_test.rb
elasticsearch-api-0.4.5 test/unit/json_builders_test.rb
elasticsearch-api-0.4.4 test/unit/json_builders_test.rb
elasticsearch-api-0.4.3 test/unit/json_builders_test.rb
elasticsearch-api-0.4.2 test/unit/json_builders_test.rb
elasticsearch-api-0.4.1 test/unit/json_builders_test.rb
elasticsearch-api-0.4.0 test/unit/json_builders_test.rb
elasticsearch-api-0.0.2 test/unit/json_builders_test.rb