Sha256: 029897d7bad2e9867705b7fcb2aa2f89ff3b8b0dfb2b308efd6fe7818ff78aab

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

require "spec_helper"
require_relative "entity_lookup_models"

describe Shamu::Entities::OpaqueEntityLookupService do
  let( :service ) { scorpion.new Shamu::Entities::OpaqueEntityLookupService }

  describe "#ids" do
    it "obfuscates the ids" do
      entity = EntityLookupServiceSpecs::ExampleEntity.new( id: 5 )
      expect( service.ids( entity ) ).not_to include( match( /EntityLookupServiceSpecs/ ) )
    end
  end

  describe "#record_ids" do
    it "gets the original record id" do
      entity = EntityLookupServiceSpecs::ExampleEntity.new( id: 5 )
      id     = service.ids( entity ).first

      expect( service.record_ids( id ).first ).to eq( 5 )
    end
  end

  describe "#lookup" do
    let( :examples_service ) { double( EntityLookupServiceSpecs::ExamplesService ) }

    before( :each ) do
      allow( service.scorpion ).to receive( :fetch )
        .with( EntityLookupServiceSpecs::ExamplesService )
        .and_return( examples_service )
    end

    it "finds an entity" do
      expect( examples_service ).to receive( :lookup ).with( "4" ).and_return [ "Found" ]
      id = service.ids( "EntityLookupServiceSpecs::Example[4]" ).first

      expect( service.lookup( id ).to_a ).to eq [ "Found" ]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.21 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.20 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.19 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.18 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.17 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.15 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb
shamu-0.0.14 spec/lib/shamu/entities/opaque_entity_lookup_service_spec.rb