websocket 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +11 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +5 -0
  5. data/README.md +117 -0
  6. data/Rakefile +23 -0
  7. data/autobahn-client.json +11 -0
  8. data/autobahn-server.json +10 -0
  9. data/examples/base.rb +162 -0
  10. data/examples/client.rb +70 -0
  11. data/examples/server.rb +56 -0
  12. data/examples/tests/autobahn_client.rb +52 -0
  13. data/examples/tests/echo_client.rb +42 -0
  14. data/examples/tests/echo_server.rb +45 -0
  15. data/lib/websocket.rb +16 -0
  16. data/lib/websocket/frame.rb +11 -0
  17. data/lib/websocket/frame/base.rb +45 -0
  18. data/lib/websocket/frame/data.rb +52 -0
  19. data/lib/websocket/frame/handler.rb +15 -0
  20. data/lib/websocket/frame/handler/base.rb +41 -0
  21. data/lib/websocket/frame/handler/handler03.rb +162 -0
  22. data/lib/websocket/frame/handler/handler04.rb +19 -0
  23. data/lib/websocket/frame/handler/handler05.rb +17 -0
  24. data/lib/websocket/frame/handler/handler07.rb +34 -0
  25. data/lib/websocket/frame/handler/handler75.rb +79 -0
  26. data/lib/websocket/frame/incoming.rb +43 -0
  27. data/lib/websocket/frame/incoming/client.rb +9 -0
  28. data/lib/websocket/frame/incoming/server.rb +9 -0
  29. data/lib/websocket/frame/outgoing.rb +28 -0
  30. data/lib/websocket/frame/outgoing/client.rb +9 -0
  31. data/lib/websocket/frame/outgoing/server.rb +9 -0
  32. data/lib/websocket/handshake.rb +10 -0
  33. data/lib/websocket/handshake/base.rb +67 -0
  34. data/lib/websocket/handshake/client.rb +80 -0
  35. data/lib/websocket/handshake/handler.rb +20 -0
  36. data/lib/websocket/handshake/handler/base.rb +25 -0
  37. data/lib/websocket/handshake/handler/client.rb +19 -0
  38. data/lib/websocket/handshake/handler/client01.rb +19 -0
  39. data/lib/websocket/handshake/handler/client04.rb +47 -0
  40. data/lib/websocket/handshake/handler/client75.rb +25 -0
  41. data/lib/websocket/handshake/handler/client76.rb +85 -0
  42. data/lib/websocket/handshake/handler/server.rb +30 -0
  43. data/lib/websocket/handshake/handler/server04.rb +38 -0
  44. data/lib/websocket/handshake/handler/server75.rb +26 -0
  45. data/lib/websocket/handshake/handler/server76.rb +71 -0
  46. data/lib/websocket/handshake/server.rb +56 -0
  47. data/lib/websocket/version.rb +3 -0
  48. data/spec/frame/incoming_03_spec.rb +117 -0
  49. data/spec/frame/incoming_04_spec.rb +117 -0
  50. data/spec/frame/incoming_05_spec.rb +133 -0
  51. data/spec/frame/incoming_07_spec.rb +133 -0
  52. data/spec/frame/incoming_75_spec.rb +59 -0
  53. data/spec/frame/incoming_common_spec.rb +22 -0
  54. data/spec/frame/outgoing_03_spec.rb +77 -0
  55. data/spec/frame/outgoing_04_spec.rb +77 -0
  56. data/spec/frame/outgoing_05_spec.rb +77 -0
  57. data/spec/frame/outgoing_07_spec.rb +77 -0
  58. data/spec/frame/outgoing_75_spec.rb +41 -0
  59. data/spec/frame/outgoing_common_spec.rb +15 -0
  60. data/spec/handshake/client_04_spec.rb +20 -0
  61. data/spec/handshake/client_75_spec.rb +11 -0
  62. data/spec/handshake/client_76_spec.rb +20 -0
  63. data/spec/handshake/server_04_spec.rb +18 -0
  64. data/spec/handshake/server_75_spec.rb +11 -0
  65. data/spec/handshake/server_76_spec.rb +46 -0
  66. data/spec/spec_helper.rb +4 -0
  67. data/spec/support/all_client_drafts.rb +77 -0
  68. data/spec/support/all_server_drafts.rb +86 -0
  69. data/spec/support/handshake_requests.rb +72 -0
  70. data/spec/support/incoming_frames.rb +30 -0
  71. data/spec/support/outgoing_frames.rb +14 -0
  72. data/websocket.gemspec +21 -0
  73. metadata +163 -0
@@ -0,0 +1,3 @@
1
+ module WebSocket
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Incoming frame draft 03' do
4
+ let(:version) { 3 }
5
+ let(:frame) { WebSocket::Frame::Incoming.new(:version => version, :data => encoded_text) }
6
+ let(:encoded_text) { nil }
7
+ let(:decoded_text) { nil }
8
+ let(:frame_type) { nil }
9
+ let(:error) { nil }
10
+ subject { frame }
11
+
12
+ it_should_behave_like 'valid_incoming_frame'
13
+
14
+ context "should properly decode close frame" do
15
+ let(:encoded_text) { "\x01\x05" + decoded_text }
16
+ let(:frame_type) { :close }
17
+ let(:decoded_text) { "Hello" }
18
+
19
+ it_should_behave_like 'valid_incoming_frame'
20
+ end
21
+
22
+ context "should properly decode ping frame" do
23
+ let(:encoded_text) { "\x02\x05" + decoded_text }
24
+ let(:frame_type) { :ping }
25
+ let(:decoded_text) { "Hello" }
26
+
27
+ it_should_behave_like 'valid_incoming_frame'
28
+ end
29
+
30
+ context "should properly decode pong frame" do
31
+ let(:encoded_text) { "\x03\x05" + decoded_text }
32
+ let(:frame_type) { :pong }
33
+ let(:decoded_text) { "Hello" }
34
+
35
+ it_should_behave_like 'valid_incoming_frame'
36
+ end
37
+
38
+ context "should properly decode text frame" do
39
+ let(:encoded_text) { "\x04\x05" + decoded_text }
40
+ let(:decoded_text) { "Hello" }
41
+ let(:frame_type) { :text }
42
+
43
+ it_should_behave_like 'valid_incoming_frame'
44
+ end
45
+
46
+ context "should properly decode text frame with continuation" do
47
+ let(:encoded_text) { "\x84\x03Hel\x00\x02lo" }
48
+ let(:frame_type) { :text }
49
+ let(:decoded_text) { "Hello" }
50
+
51
+ it_should_behave_like 'valid_incoming_frame'
52
+ end
53
+
54
+ context "should properly decode text frame in between of continuation" do
55
+ let(:encoded_text) { "\x84\x03Hel\x03\x03abc\x00\x02lo" }
56
+ let(:frame_type) { [:pong, :text] }
57
+ let(:decoded_text) { ["abc", "Hello"] }
58
+
59
+ it_should_behave_like 'valid_incoming_frame'
60
+ end
61
+
62
+ context "should not return unfinished more frame" do
63
+ let(:encoded_text) { "\x84\x03Hel\x03\x03abc" }
64
+ let(:frame_type) { :pong }
65
+ let(:decoded_text) { "abc" }
66
+
67
+ it_should_behave_like 'valid_incoming_frame'
68
+ end
69
+
70
+ context "should properly decode 256 bytes binary frame" do
71
+ let(:encoded_text) { "\x05\x7E\x01\x00" + decoded_text }
72
+ let(:frame_type) { :binary }
73
+ let(:decoded_text) { "a" * 256 }
74
+
75
+ it_should_behave_like 'valid_incoming_frame'
76
+ end
77
+
78
+ context "should properly decode 64KiB binary frame" do
79
+ let(:encoded_text) { "\x05\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
80
+ let(:frame_type) { :binary }
81
+ let(:decoded_text) { "a" * 65536 }
82
+
83
+ it_should_behave_like 'valid_incoming_frame'
84
+ end
85
+
86
+ context "should wait with incomplete frame" do
87
+ let(:encoded_text) { "\x04\x06Hello" }
88
+ let(:decoded_text) { nil }
89
+
90
+ it_should_behave_like 'valid_incoming_frame'
91
+ end
92
+
93
+ context "should raise error with invalid opcode" do
94
+ let(:encoded_text) { "\x09\x05Hello" }
95
+ let(:decoded_text) { nil }
96
+ let(:error) { :unknown_opcode }
97
+
98
+ it_should_behave_like 'valid_incoming_frame'
99
+ end
100
+
101
+ context "should raise error with too long frame" do
102
+ let(:encoded_text) { "\x04\x7F" + "a" * WebSocket::Frame::Handler::Base::MAX_FRAME_SIZE }
103
+ let(:decoded_text) { nil }
104
+ let(:error) { :frame_too_long }
105
+
106
+ it_should_behave_like('valid_incoming_frame') unless RUBY_PLATFORM == "java"
107
+ end
108
+
109
+ context "should raise error with continuation frame without more frame earlier" do
110
+ let(:encoded_text) { "\x00\x05Hello" }
111
+ let(:decoded_text) { nil }
112
+ let(:error) { :unexpected_continuation_frame }
113
+
114
+ it_should_behave_like 'valid_incoming_frame'
115
+ end
116
+
117
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Incoming frame draft 04' do
4
+ let(:version) { 4 }
5
+ let(:frame) { WebSocket::Frame::Incoming.new(:version => version, :data => encoded_text) }
6
+ let(:encoded_text) { nil }
7
+ let(:decoded_text) { nil }
8
+ let(:frame_type) { nil }
9
+ let(:error) { nil }
10
+ subject { frame }
11
+
12
+ it_should_behave_like 'valid_incoming_frame'
13
+
14
+ context "should properly decode close frame" do
15
+ let(:encoded_text) { "\x81\x05" + decoded_text }
16
+ let(:frame_type) { :close }
17
+ let(:decoded_text) { "Hello" }
18
+
19
+ it_should_behave_like 'valid_incoming_frame'
20
+ end
21
+
22
+ context "should properly decode ping frame" do
23
+ let(:encoded_text) { "\x82\x05" + decoded_text }
24
+ let(:frame_type) { :ping }
25
+ let(:decoded_text) { "Hello" }
26
+
27
+ it_should_behave_like 'valid_incoming_frame'
28
+ end
29
+
30
+ context "should properly decode pong frame" do
31
+ let(:encoded_text) { "\x83\x05" + decoded_text }
32
+ let(:frame_type) { :pong }
33
+ let(:decoded_text) { "Hello" }
34
+
35
+ it_should_behave_like 'valid_incoming_frame'
36
+ end
37
+
38
+ context "should properly decode text frame" do
39
+ let(:encoded_text) { "\x84\x05" + decoded_text }
40
+ let(:decoded_text) { "Hello" }
41
+ let(:frame_type) { :text }
42
+
43
+ it_should_behave_like 'valid_incoming_frame'
44
+ end
45
+
46
+ context "should properly decode text frame with continuation" do
47
+ let(:encoded_text) { "\x04\x03Hel\x80\x02lo" }
48
+ let(:frame_type) { :text }
49
+ let(:decoded_text) { "Hello" }
50
+
51
+ it_should_behave_like 'valid_incoming_frame'
52
+ end
53
+
54
+ context "should properly decode text frame in between of continuation" do
55
+ let(:encoded_text) { "\x04\x03Hel\x83\x03abc\x80\x02lo" }
56
+ let(:frame_type) { [:pong, :text] }
57
+ let(:decoded_text) { ["abc", "Hello"] }
58
+
59
+ it_should_behave_like 'valid_incoming_frame'
60
+ end
61
+
62
+ context "should not return unfinished more frame" do
63
+ let(:encoded_text) { "\x04\x03Hel\x83\x03abc" }
64
+ let(:frame_type) { :pong }
65
+ let(:decoded_text) { "abc" }
66
+
67
+ it_should_behave_like 'valid_incoming_frame'
68
+ end
69
+
70
+ context "should properly decode 256 bytes binary frame" do
71
+ let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
72
+ let(:frame_type) { :binary }
73
+ let(:decoded_text) { "a" * 256 }
74
+
75
+ it_should_behave_like 'valid_incoming_frame'
76
+ end
77
+
78
+ context "should properly decode 64KiB binary frame" do
79
+ let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
80
+ let(:frame_type) { :binary }
81
+ let(:decoded_text) { "a" * 65536 }
82
+
83
+ it_should_behave_like 'valid_incoming_frame'
84
+ end
85
+
86
+ context "should wait with incomplete frame" do
87
+ let(:encoded_text) { "\x84\x06Hello" }
88
+ let(:decoded_text) { nil }
89
+
90
+ it_should_behave_like 'valid_incoming_frame'
91
+ end
92
+
93
+ context "should raise error with invalid opcode" do
94
+ let(:encoded_text) { "\x89\x05Hello" }
95
+ let(:decoded_text) { nil }
96
+ let(:error) { :unknown_opcode }
97
+
98
+ it_should_behave_like 'valid_incoming_frame'
99
+ end
100
+
101
+ context "should raise error with too long frame" do
102
+ let(:encoded_text) { "\x84\x7F" + "a" * WebSocket::Frame::Handler::Base::MAX_FRAME_SIZE }
103
+ let(:decoded_text) { nil }
104
+ let(:error) { :frame_too_long }
105
+
106
+ it_should_behave_like('valid_incoming_frame') unless RUBY_PLATFORM == "java"
107
+ end
108
+
109
+ context "should raise error with continuation frame without more frame earlier" do
110
+ let(:encoded_text) { "\x80\x05Hello" }
111
+ let(:decoded_text) { nil }
112
+ let(:error) { :unexpected_continuation_frame }
113
+
114
+ it_should_behave_like 'valid_incoming_frame'
115
+ end
116
+
117
+ end
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Incoming frame draft 05' do
4
+ let(:version) { 5 }
5
+ let(:frame) { WebSocket::Frame::Incoming.new(:version => version, :data => encoded_text) }
6
+ let(:encoded_text) { nil }
7
+ let(:decoded_text) { nil }
8
+ let(:frame_type) { nil }
9
+ let(:error) { nil }
10
+ subject { frame }
11
+
12
+ it_should_behave_like 'valid_incoming_frame'
13
+
14
+ context "should properly decode close frame" do
15
+ let(:encoded_text) { "\x81\x05" + decoded_text }
16
+ let(:frame_type) { :close }
17
+ let(:decoded_text) { "Hello" }
18
+
19
+ it_should_behave_like 'valid_incoming_frame'
20
+ end
21
+
22
+ context "should properly decode ping frame" do
23
+ let(:encoded_text) { "\x82\x05" + decoded_text }
24
+ let(:frame_type) { :ping }
25
+ let(:decoded_text) { "Hello" }
26
+
27
+ it_should_behave_like 'valid_incoming_frame'
28
+ end
29
+
30
+ context "should properly decode pong frame" do
31
+ let(:encoded_text) { "\x83\x05" + decoded_text }
32
+ let(:frame_type) { :pong }
33
+ let(:decoded_text) { "Hello" }
34
+
35
+ it_should_behave_like 'valid_incoming_frame'
36
+ end
37
+
38
+ context "should properly decode text frame" do
39
+ let(:encoded_text) { "\x84\x05" + decoded_text }
40
+ let(:decoded_text) { "Hello" }
41
+ let(:frame_type) { :text }
42
+
43
+ it_should_behave_like 'valid_incoming_frame'
44
+ end
45
+
46
+ context "should properly decode masked text frame" do
47
+ let(:encoded_text) { "\x84\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58" }
48
+ let(:decoded_text) { "Hello" }
49
+ let(:frame_type) { :text }
50
+
51
+ it_should_behave_like 'valid_incoming_frame'
52
+ end
53
+
54
+ context "should properly decode text frame with continuation" do
55
+ let(:encoded_text) { "\x04\x03Hel\x80\x02lo" }
56
+ let(:frame_type) { :text }
57
+ let(:decoded_text) { "Hello" }
58
+
59
+ it_should_behave_like 'valid_incoming_frame'
60
+ end
61
+
62
+ context "should properly decode masked text frame with continuation" do
63
+ let(:encoded_text) { "\x04\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x37\xfa\x21\x3d\x5b\x95" }
64
+ let(:frame_type) { :text }
65
+ let(:decoded_text) { "Hello" }
66
+
67
+ it_should_behave_like 'valid_incoming_frame'
68
+ end
69
+
70
+ context "should properly decode text frame in between of continuation" do
71
+ let(:encoded_text) { "\x04\x03Hel\x83\x03abc\x80\x02lo" }
72
+ let(:frame_type) { [:pong, :text] }
73
+ let(:decoded_text) { ["abc", "Hello"] }
74
+
75
+ it_should_behave_like 'valid_incoming_frame'
76
+ end
77
+
78
+ context "should not return unfinished more frame" do
79
+ let(:encoded_text) { "\x04\x03Hel\x83\x03abc" }
80
+ let(:frame_type) { :pong }
81
+ let(:decoded_text) { "abc" }
82
+
83
+ it_should_behave_like 'valid_incoming_frame'
84
+ end
85
+
86
+ context "should properly decode 256 bytes binary frame" do
87
+ let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
88
+ let(:frame_type) { :binary }
89
+ let(:decoded_text) { "a" * 256 }
90
+
91
+ it_should_behave_like 'valid_incoming_frame'
92
+ end
93
+
94
+ context "should properly decode 64KiB binary frame" do
95
+ let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
96
+ let(:frame_type) { :binary }
97
+ let(:decoded_text) { "a" * 65536 }
98
+
99
+ it_should_behave_like 'valid_incoming_frame'
100
+ end
101
+
102
+ context "should wait with incomplete frame" do
103
+ let(:encoded_text) { "\x84\x06Hello" }
104
+ let(:decoded_text) { nil }
105
+
106
+ it_should_behave_like 'valid_incoming_frame'
107
+ end
108
+
109
+ context "should raise error with invalid opcode" do
110
+ let(:encoded_text) { "\x89\x05Hello" }
111
+ let(:decoded_text) { nil }
112
+ let(:error) { :unknown_opcode }
113
+
114
+ it_should_behave_like 'valid_incoming_frame'
115
+ end
116
+
117
+ context "should raise error with too long frame" do
118
+ let(:encoded_text) { "\x84\x7F" + "a" * WebSocket::Frame::Handler::Base::MAX_FRAME_SIZE }
119
+ let(:decoded_text) { nil }
120
+ let(:error) { :frame_too_long }
121
+
122
+ it_should_behave_like('valid_incoming_frame') unless RUBY_PLATFORM == "java"
123
+ end
124
+
125
+ context "should raise error with continuation frame without more frame earlier" do
126
+ let(:encoded_text) { "\x80\x05Hello" }
127
+ let(:decoded_text) { nil }
128
+ let(:error) { :unexpected_continuation_frame }
129
+
130
+ it_should_behave_like 'valid_incoming_frame'
131
+ end
132
+
133
+ end
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Incoming frame draft 07' do
4
+ let(:version) { 7 }
5
+ let(:frame) { WebSocket::Frame::Incoming.new(:version => version, :data => encoded_text) }
6
+ let(:encoded_text) { nil }
7
+ let(:decoded_text) { nil }
8
+ let(:frame_type) { nil }
9
+ let(:error) { nil }
10
+ subject { frame }
11
+
12
+ it_should_behave_like 'valid_incoming_frame'
13
+
14
+ context "should properly decode close frame" do
15
+ let(:encoded_text) { "\x88\x05" + decoded_text }
16
+ let(:frame_type) { :close }
17
+ let(:decoded_text) { "Hello" }
18
+
19
+ it_should_behave_like 'valid_incoming_frame'
20
+ end
21
+
22
+ context "should properly decode ping frame" do
23
+ let(:encoded_text) { "\x89\x05" + decoded_text }
24
+ let(:frame_type) { :ping }
25
+ let(:decoded_text) { "Hello" }
26
+
27
+ it_should_behave_like 'valid_incoming_frame'
28
+ end
29
+
30
+ context "should properly decode pong frame" do
31
+ let(:encoded_text) { "\x8a\x05" + decoded_text }
32
+ let(:frame_type) { :pong }
33
+ let(:decoded_text) { "Hello" }
34
+
35
+ it_should_behave_like 'valid_incoming_frame'
36
+ end
37
+
38
+ context "should properly decode text frame" do
39
+ let(:encoded_text) { "\x81\x05\x48\x65\x6c\x6c\x6f" }
40
+ let(:decoded_text) { "Hello" }
41
+ let(:frame_type) { :text }
42
+
43
+ it_should_behave_like 'valid_incoming_frame'
44
+ end
45
+
46
+ context "should properly decode masked text frame" do
47
+ let(:encoded_text) { "\x81\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58" }
48
+ let(:decoded_text) { "Hello" }
49
+ let(:frame_type) { :text }
50
+
51
+ it_should_behave_like 'valid_incoming_frame'
52
+ end
53
+
54
+ context "should properly decode text frame with continuation" do
55
+ let(:encoded_text) { "\x01\x03Hel\x80\x02lo" }
56
+ let(:frame_type) { :text }
57
+ let(:decoded_text) { "Hello" }
58
+
59
+ it_should_behave_like 'valid_incoming_frame'
60
+ end
61
+
62
+ context "should properly decode masked text frame with continuation" do
63
+ let(:encoded_text) { "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x37\xfa\x21\x3d\x5b\x95" }
64
+ let(:frame_type) { :text }
65
+ let(:decoded_text) { "Hello" }
66
+
67
+ it_should_behave_like 'valid_incoming_frame'
68
+ end
69
+
70
+ context "should properly decode text frame in between of continuation" do
71
+ let(:encoded_text) { "\x01\x03Hel\x8a\x03abc\x80\x02lo" }
72
+ let(:frame_type) { [:pong, :text] }
73
+ let(:decoded_text) { ["abc", "Hello"] }
74
+
75
+ it_should_behave_like 'valid_incoming_frame'
76
+ end
77
+
78
+ context "should not return unfinished more frame" do
79
+ let(:encoded_text) { "\x01\x03Hel\x8a\x03abc" }
80
+ let(:frame_type) { :pong }
81
+ let(:decoded_text) { "abc" }
82
+
83
+ it_should_behave_like 'valid_incoming_frame'
84
+ end
85
+
86
+ context "should properly decode 256 bytes binary frame" do
87
+ let(:encoded_text) { "\x82\x7E\x01\x00" + decoded_text }
88
+ let(:frame_type) { :binary }
89
+ let(:decoded_text) { "a" * 256 }
90
+
91
+ it_should_behave_like 'valid_incoming_frame'
92
+ end
93
+
94
+ context "should properly decode 64KiB binary frame" do
95
+ let(:encoded_text) { "\x82\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
96
+ let(:frame_type) { :binary }
97
+ let(:decoded_text) { "a" * 65536 }
98
+
99
+ it_should_behave_like 'valid_incoming_frame'
100
+ end
101
+
102
+ context "should wait with incomplete frame" do
103
+ let(:encoded_text) { "\x81\x06Hello" }
104
+ let(:decoded_text) { nil }
105
+
106
+ it_should_behave_like 'valid_incoming_frame'
107
+ end
108
+
109
+ context "should raise error with invalid opcode" do
110
+ let(:encoded_text) { "\x85\x05Hello" }
111
+ let(:decoded_text) { nil }
112
+ let(:error) { :unknown_opcode }
113
+
114
+ it_should_behave_like 'valid_incoming_frame'
115
+ end
116
+
117
+ context "should raise error with too long frame" do
118
+ let(:encoded_text) { "\x81\x7F" + "a" * WebSocket::Frame::Handler::Base::MAX_FRAME_SIZE }
119
+ let(:decoded_text) { nil }
120
+ let(:error) { :frame_too_long }
121
+
122
+ it_should_behave_like('valid_incoming_frame') unless RUBY_PLATFORM == "java"
123
+ end
124
+
125
+ context "should raise error with continuation frame without more frame earlier" do
126
+ let(:encoded_text) { "\x80\x05Hello" }
127
+ let(:decoded_text) { nil }
128
+ let(:error) { :unexpected_continuation_frame }
129
+
130
+ it_should_behave_like 'valid_incoming_frame'
131
+ end
132
+
133
+ end