File: grammar_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 (68 lines) | stat: -rw-r--r-- 2,031 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require "spec_helper"

describe Faye::Grammar do
  describe :CHANNEL_NAME do
    it "matches valid channel names" do
      Faye::Grammar::CHANNEL_NAME.should =~ "/fo_o/$@()bar"
    end

    it "does not match channel patterns" do
      Faye::Grammar::CHANNEL_NAME.should_not =~ "/foo/**"
    end

    it "does not match invalid channel names" do
      Faye::Grammar::CHANNEL_NAME.should_not =~ "foo/$@()bar"
      Faye::Grammar::CHANNEL_NAME.should_not =~ "/foo/$@()bar/"
      Faye::Grammar::CHANNEL_NAME.should_not =~ "/fo o/$@()bar"
    end
  end

  describe :CHANNEL_PATTERN do
    it "does not match channel names" do
      Faye::Grammar::CHANNEL_PATTERN.should_not =~ "/fo_o/$@()bar"
    end

    it "matches valid channel patterns" do
      Faye::Grammar::CHANNEL_PATTERN.should =~ "/foo/**"
      Faye::Grammar::CHANNEL_PATTERN.should =~ "/foo/*"
    end

    it "does not match invalid channel patterns" do
      Faye::Grammar::CHANNEL_PATTERN.should_not =~ "/foo/**/*"
    end
  end

  describe :ERROR do
    it "matches an error with an argument" do
      Faye::Grammar::ERROR.should =~ "402:xj3sjdsjdsjad:Unknown Client ID"
    end

    it "matches an error with many arguments" do
      Faye::Grammar::ERROR.should =~ "403:xj3sjdsjdsjad,/foo/bar:Subscription denied"
    end

    it "matches an error with no arguments" do
      Faye::Grammar::ERROR.should =~ "402::Unknown Client ID"
    end

    it "does not match an error with no code" do
      Faye::Grammar::ERROR.should_not =~ ":xj3sjdsjdsjad:Unknown Client ID"
    end

    it "does not match an error with an invalid code" do
      Faye::Grammar::ERROR.should_not =~ "40:xj3sjdsjdsjad:Unknown Client ID"
    end
  end

  describe :VERSION do
    it "matches a version number" do
      Faye::Grammar::VERSION.should =~ "9"
      Faye::Grammar::VERSION.should =~ "9.0.a-delta1"
    end

    it "does not match invalid version numbers" do
      Faye::Grammar::VERSION.should_not =~ "9.0.a-delta1."
      Faye::Grammar::VERSION.should_not =~ ""
    end
  end
end