spec/subscription_spec.rb in fakeredis-0.7.0 vs spec/subscription_spec.rb in fakeredis-0.8.0
- old
+ new
@@ -4,104 +4,104 @@
module FakeRedis
describe "SubscriptionMethods" do
before(:each) do
@client = Redis.new
end
-
+
context "publish" do
it "should add to channels" do
- @client.publish("channel1", "val1").should be == 0
- @client.publish("channel1", "val2").should be == 0
+ expect(@client.publish("channel1", "val1")).to eq(0)
+ expect(@client.publish("channel1", "val2")).to eq(0)
end
end
-
+
context "subscribe" do
it "should get all messages from a channel" do
@client.publish("channel1", "val1")
@client.publish("channel1", "val2")
@client.publish("channel2", "val3")
-
+
msgs = []
subscribe_sent = unsubscribe_sent = false
Timeout.timeout(1) do
@client.subscribe("channel1") do |on|
on.subscribe do |channel|
subscribe_sent = true
- channel.should be == "channel1"
+ expect(channel).to eq("channel1")
end
-
+
on.message do |channel,msg|
- channel.should be == "channel1"
+ expect(channel).to eq("channel1")
msgs << msg
end
-
+
on.unsubscribe do
unsubscribe_sent = true
end
end
end
-
- msgs.should be == ["val1", "val2"]
- subscribe_sent.should
- unsubscribe_sent.should
+
+ expect(msgs).to eq(["val1", "val2"])
+ expect(subscribe_sent).to eq(true)
+ expect(unsubscribe_sent).to eq(true)
end
-
+
it "should get all messages from multiple channels" do
@client.publish("channel1", "val1")
@client.publish("channel2", "val2")
@client.publish("channel2", "val3")
-
+
msgs = []
Timeout.timeout(1) do
@client.subscribe("channel1", "channel2") do |on|
on.message do |channel,msg|
msgs << [channel, msg]
end
end
end
-
- msgs[0].should be == ["channel1", "val1"]
- msgs[1].should be == ["channel2", "val2"]
- msgs[2].should be == ["channel2", "val3"]
+
+ expect(msgs[0]).to eq(["channel1", "val1"])
+ expect(msgs[1]).to eq(["channel2", "val2"])
+ expect(msgs[2]).to eq(["channel2", "val3"])
end
end
-
+
context "unsubscribe" do
end
-
+
context "with patterns" do
context "psubscribe" do
it "should get all messages using pattern" do
@client.publish("channel1", "val1")
@client.publish("channel1", "val2")
@client.publish("channel2", "val3")
-
+
msgs = []
subscribe_sent = unsubscribe_sent = false
Timeout.timeout(1) do
@client.psubscribe("channel*") do |on|
on.psubscribe do |channel|
subscribe_sent = true
end
-
+
on.pmessage do |pattern,channel,msg|
- pattern.should be == "channel*"
+ expect(pattern).to eq("channel*")
msgs << msg
end
-
+
on.punsubscribe do
unsubscribe_sent = true
end
end
end
-
- msgs.should be == ["val1", "val2", "val3"]
- subscribe_sent.should
- unsubscribe_sent.should
+
+ expect(msgs).to eq(["val1", "val2", "val3"])
+ expect(subscribe_sent).to eq(true)
+ expect(unsubscribe_sent).to eq(true)
end
end
-
+
context "punsubscribe" do
end
end
end
-end
\ No newline at end of file
+end