Sha256: d4e6345b3bc0b2be5d11623ac49ee9a17c248bd72380beeacd54e49d75d629dd

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 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 (:find_by_property) { CaseblocksAPI::Finder.new(client) }
    When (:result) { find_by_property.execute_single(case_type, property_name, value) }
    Then { expect(result).to eql client.result}
    Then { expect(client.requested_url).to eql "/case_blocks/#{case_type}" }
    Then { expect(client.params).to eql({query: {search: true, property: property_name, value: value}}) }
  end

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caseblocks_api-0.2.8 spec/lib/caseblocks_api/find_case_by_property_spec.rb