Sha256: 7f2ab835ed34c70f87032b28c88150b5c73cd3707b1aa0c865a83073e75082b0

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'


describe CaseblocksAPI::Finder do

  Given (:client) { FakeHttpParty.new }
  Given (:case_type) { 'the_case_type' }

  context "find by a single property" do
    Given (:property_name) { "order_number" }
    Given (:value) { "2000391" }
    Given (:page) { "0" }
    Given (:page_size) { "100" }
    Given (:find_by_property) { CaseblocksAPI::Finder.new(client) }
    When (:result) { find_by_property.execute_single(case_type, property_name, value, page, page_size) }
    Then { expect(result).to eql client.result}
    Then { expect(client.requested_url).to eql "/case_blocks/#{case_type}/search" }
    Then { expect(client.params).to eql({query: {search: true, property: property_name, value: value, page: page, page_size: page_size}}) }
  end

  context "finding by multiple properties" do
    Given (:properties) { {order_number: '12334', client_surname: 'Smith'} }
    Given (:page) { "0" }
    Given (:page_size) { "100" }
    Given (:find_by_properties) { CaseblocksAPI::Finder.new(client) }
    When (:result) { find_by_properties.execute_multiple(case_type, properties, page, page_size) }
    Then { expect(client.requested_url).to eql "/case_blocks/#{case_type}/search" }
    Then { expect(client.params).to eql({body: {search: true, properties: properties, page: page, page_size: page_size}.to_json}) }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caseblocks_api-0.2.12 spec/lib/caseblocks_api/find_case_by_property_spec.rb
caseblocks_api-0.2.11 spec/lib/caseblocks_api/find_case_by_property_spec.rb