spec/redstream_spec.rb in redstream-0.0.1 vs spec/redstream_spec.rb in redstream-0.1.0
- old
+ new
@@ -1,6 +1,5 @@
-
require File.expand_path("spec_helper", __dir__)
RSpec.describe Redstream do
describe ".connection_pool=" do
it "sets the connection pool" do
@@ -29,26 +28,36 @@
Redstream.connection_pool = connection_pool
end
end
end
+ describe ".stream_size" do
+ it "returns the stream's size" do
+ expect(Redstream.stream_size("products")).to eq(0)
+
+ redis.xadd("redstream:stream:products", key: "value")
+
+ expect(Redstream.stream_size("products")).to eq(1)
+ end
+ end
+
describe ".max_stream_id" do
it "returns the stream's max id" do
expect(Redstream.max_stream_id("products")).to be_nil
- id1 = redis.xadd("redstream:stream:products", key: "value")
+ _id1 = redis.xadd("redstream:stream:products", key: "value")
id2 = redis.xadd("redstream:stream:products", key: "value")
expect(Redstream.max_stream_id("products")).to eq(id2)
end
end
describe ".max_consumer_id" do
it "returns the consumer's max id" do
expect(Redstream.max_consumer_id(stream_name: "products", consumer_name: "consumer")).to be_nil
- id1 = redis.xadd("redstream:stream:products", key: "value")
+ _id1 = redis.xadd("redstream:stream:products", key: "value")
id2 = redis.xadd("redstream:stream:products", key: "value")
Redstream::Consumer.new(name: "consumer", stream_name: "products").run_once do |messages|
# nothing
end
@@ -112,6 +121,5 @@
end
end
end
end
end
-