Sha256: 6c72114a868fa50b628df235cb439c0e938539a358c76e99cd9930a7cf934a97

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 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({query: {search: true, properties: properties}}) }
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
caseblocks_api-0.2.6 spec/lib/caseblocks_api/find_case_by_property_spec.rb
caseblocks_api-0.2.5 spec/lib/caseblocks_api/find_case_by_property_spec.rb
caseblocks_api-0.2.4 spec/lib/caseblocks_api/find_case_by_property_spec.rb
caseblocks_api-0.2.3 spec/lib/caseblocks_api/find_case_by_property_spec.rb