Sha256: 3d26b46ae1098775f2a87936636166ddf80e4d90749005e90e6474bf1cf5d522

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Split::RedisInterface do
  let(:list_name) { "list_name" }
  let(:set_name) { "set_name" }
  let(:interface) { described_class.new }

  describe "#persist_list" do
    subject(:persist_list) do
      interface.persist_list(list_name, %w(a b c d))
    end

    specify do
      expect(persist_list).to eq %w(a b c d)
      expect(Split.redis.lindex(list_name, 0)).to eq "a"
      expect(Split.redis.lindex(list_name, 1)).to eq "b"
      expect(Split.redis.lindex(list_name, 2)).to eq "c"
      expect(Split.redis.lindex(list_name, 3)).to eq "d"
      expect(Split.redis.llen(list_name)).to eq 4
    end

    context "list is overwritten but not deleted" do
      specify do
        expect(persist_list).to eq %w(a b c d)
        interface.persist_list(list_name, ["z"])
        expect(Split.redis.lindex(list_name, 0)).to eq "z"
        expect(Split.redis.llen(list_name)).to eq 1
      end
    end
  end

  describe "#add_to_set" do
    subject(:add_to_set) do
      interface.add_to_set(set_name, "something")
    end

    specify do
      add_to_set
      expect(Split.redis.sismember(set_name, "something")).to be true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
split-4.0.2 spec/redis_interface_spec.rb