Sha256: 94198d40da314cb3d81e7ca8af98a39206cca9c3fa6919184145336b82dd0b61

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe CaseblocksAPI::Searcher do

  let(:client) { double('client') }
  let(:finder) { CaseblocksAPI::Searcher.new(client) }
  let(:case_type) { 'the_case_type' }

  context "search with case type alone and empty properties" do
      it "should pass them onto a POST request" do
        expected_body = {body: {properties: {}}.to_json}
        client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
        finder.execute_search(case_type, {})
      end
  end

  context "search with case type with properties" do
      it "should pass them onto a POST request" do
        expected_body = {body: {properties: {order_number: '12334', client_surname: 'Smith'}}.to_json}
        client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
        finder.execute_search(case_type, {order_number: '12334', client_surname: 'Smith'})
      end
  end

  context "search with case type with properties and options" do
      it "should pass them onto a POST request" do
        expected_body = {body: {properties: {order_number: '12334', client_surname: 'Smith'}, page: 0, page_size: 10}.to_json}
        client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
        finder.execute_search(case_type, {order_number: '12334', client_surname: 'Smith'}, page: 0, page_size: 10)
      end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
caseblocks_api-0.2.20 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.19 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.18 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.17 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.16 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.15 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.14 spec/lib/caseblocks_api/searcher_spec.rb
caseblocks_api-0.2.13 spec/lib/caseblocks_api/searcher_spec.rb