File: channel_spec.rb

package info (click to toggle)
ruby-faye 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,792 kB
  • sloc: javascript: 14,833; ruby: 5,068; makefile: 30
file content (27 lines) | stat: -rw-r--r-- 838 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require "spec_helper"

describe Faye::Channel do
  describe :expand do
    it "returns all patterns that match a channel" do
      Faye::Channel.expand("/foo").should == [
                           "/**", "/foo", "/*"]

      Faye::Channel.expand("/foo/bar").should == [
                           "/**", "/foo/bar", "/foo/*", "/foo/**"]

      Faye::Channel.expand("/foo/bar/qux").should == [
                           "/**", "/foo/bar/qux", "/foo/bar/*", "/foo/**", "/foo/bar/**"]
    end
  end

  describe Faye::Channel::Set do
    describe :subscribe do
      it "subscribes and unsubscribes without callback" do
        channels = Faye::Channel::Set.new
        channels.subscribe(["/foo/**"], nil)
        channels.keys.should == ["/foo/**"]
        channels.unsubscribe("/foo/**", nil).should == true
      end
    end
  end
end