Sha256: bc7a34c95593b8ddac01461d53b46cd3d636bdf76d2f3bdb4d1d354ac9e3c8eb

Contents?: true

Size: 637 Bytes

Versions: 7

Compression:

Stored size: 637 Bytes

Contents

require 'spec_helper'

RSpec.describe Cache::Object::InstanceDecorator do
  let(:decorator) { Cache::Object::InstanceDecorator.new(instance, mappings) }

  describe '#keys' do
    let(:instance) { double(id: 1, user_id: 11, sex: 'male', class: double(name: 'User', primary_key: :id)) }
    let(:mappings) { [[:user_id] , [:user_id, :sex]] }

    it 'includes the keys based on the mappings' do
      expect(decorator.keys).to include 'User-user_id-11'
      expect(decorator.keys).to include 'User-user_id-11-sex-male'
    end

    it 'includes the canonical id key' do
      expect(decorator.keys).to include 'User-1'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cache-object-0.2.0 spec/cache/object/instance_decorator_spec.rb
cache-object-0.1.0 spec/cache/object/instance_decorator_spec.rb
cache-object-0.0.7 spec/cache/object/instance_decorator_spec.rb
cache-object-0.0.6 spec/cache/object/instance_decorator_spec.rb
cache-object-0.0.5 spec/cache/object/instance_decorator_spec.rb
cache-object-0.0.4 spec/cache/object/instance_decorator_spec.rb
cache-object-0.0.3 spec/cache/object/instance_decorator_spec.rb