Sha256: 37d0a0aea523346aa69a2004c779830a46d7f0fc9e8e0c90a821ab694706f14f

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

# rubocop:disable RSpec/FilePath

module SimpleRedisOrm
  RSpec.describe Entry do
    let(:subject_class) do
      Class.new(Entry) do
        attribute :password, Types::String.optional

        def self.redis
          Entry.redis
        end
      end
    end

    let(:id) { 'some-key' }
    let(:attributes) { { password: 'some-password' } }
    let(:instance) { subject_class.new(id: 'desoleary@gmail.com', **attributes) }

    subject(:entry) { instance.save }

    describe '.new' do
      it 'initializes instance' do
        instance = subject_class.new(id: id, **attributes)

        expect(instance.id).to eql(id)
        expect(instance.read).to be_nil
      end
    end

    describe '.save' do
      it 'initializes instance' do
        instance.save

        expect(instance.read).to eql(attributes)
      end
    end

    describe '.create' do
      it 'stores record' do
        actual = subject_class.create(id: id, **attributes)

        expect(actual.id).to eql(id)

        entry = subject_class.find(id)
        expect(entry.attributes).to eql(attributes)
      end
    end

    describe '.find' do
      it 'stores hash data into redis store' do
        entry

        actual = subject_class.find('desoleary@gmail.com')
        expect(actual.attributes).to eql(attributes)
      end
    end
  end
end
# rubocop:enable RSpec/FilePath

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple-redis-orm-0.1.3 spec/simple-redis-orm/entry_spec.rb
simple-redis-orm-0.1.2 spec/simple-redis-orm/entry_spec.rb
simple-redis-orm-0.1.1 spec/simple-redis-orm/entry_spec.rb
simple-redis-orm-0.1.0 spec/simple-redis-orm/entry_spec.rb