websocket 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +4 -1
- data/.travis.yml +1 -5
- data/CHANGELOG.md +8 -0
- data/Gemfile +5 -3
- data/Rakefile +3 -1
- data/lib/websocket.rb +3 -1
- data/lib/websocket/error.rb +2 -0
- data/lib/websocket/exception_handler.rb +2 -0
- data/lib/websocket/frame.rb +2 -0
- data/lib/websocket/frame/base.rb +2 -0
- data/lib/websocket/frame/data.rb +3 -1
- data/lib/websocket/frame/handler.rb +2 -0
- data/lib/websocket/frame/handler/base.rb +4 -2
- data/lib/websocket/frame/handler/handler03.rb +5 -4
- data/lib/websocket/frame/handler/handler04.rb +1 -0
- data/lib/websocket/frame/handler/handler05.rb +1 -0
- data/lib/websocket/frame/handler/handler07.rb +2 -1
- data/lib/websocket/frame/handler/handler75.rb +2 -1
- data/lib/websocket/frame/incoming.rb +2 -0
- data/lib/websocket/frame/incoming/client.rb +2 -0
- data/lib/websocket/frame/incoming/server.rb +2 -0
- data/lib/websocket/frame/outgoing.rb +2 -0
- data/lib/websocket/frame/outgoing/client.rb +2 -0
- data/lib/websocket/frame/outgoing/server.rb +2 -0
- data/lib/websocket/handshake.rb +2 -0
- data/lib/websocket/handshake/base.rb +12 -3
- data/lib/websocket/handshake/client.rb +2 -0
- data/lib/websocket/handshake/handler.rb +2 -0
- data/lib/websocket/handshake/handler/base.rb +2 -0
- data/lib/websocket/handshake/handler/client.rb +2 -0
- data/lib/websocket/handshake/handler/client01.rb +2 -0
- data/lib/websocket/handshake/handler/client04.rb +4 -2
- data/lib/websocket/handshake/handler/client11.rb +2 -0
- data/lib/websocket/handshake/handler/client75.rb +4 -2
- data/lib/websocket/handshake/handler/client76.rb +4 -2
- data/lib/websocket/handshake/handler/server.rb +2 -0
- data/lib/websocket/handshake/handler/server04.rb +4 -2
- data/lib/websocket/handshake/handler/server75.rb +4 -2
- data/lib/websocket/handshake/handler/server76.rb +2 -0
- data/lib/websocket/handshake/server.rb +2 -0
- data/lib/websocket/nice_inspect.rb +2 -0
- data/lib/websocket/version.rb +3 -1
- data/spec/frame/incoming_03_spec.rb +18 -16
- data/spec/frame/incoming_04_spec.rb +18 -16
- data/spec/frame/incoming_05_spec.rb +20 -18
- data/spec/frame/incoming_07_spec.rb +22 -20
- data/spec/frame/incoming_75_spec.rb +11 -9
- data/spec/frame/incoming_common_spec.rb +1 -0
- data/spec/frame/masking_spec.rb +1 -0
- data/spec/frame/outgoing_03_spec.rb +10 -8
- data/spec/frame/outgoing_04_spec.rb +10 -8
- data/spec/frame/outgoing_05_spec.rb +10 -8
- data/spec/frame/outgoing_07_spec.rb +11 -9
- data/spec/frame/outgoing_75_spec.rb +6 -4
- data/spec/frame/outgoing_common_spec.rb +1 -0
- data/spec/handshake/client_04_spec.rb +6 -4
- data/spec/handshake/client_11_spec.rb +3 -1
- data/spec/handshake/client_75_spec.rb +4 -2
- data/spec/handshake/client_76_spec.rb +4 -2
- data/spec/handshake/server_04_spec.rb +4 -2
- data/spec/handshake/server_75_spec.rb +4 -2
- data/spec/handshake/server_76_spec.rb +4 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/support/all_client_drafts.rb +2 -0
- data/spec/support/all_server_drafts.rb +2 -0
- data/spec/support/frames_base.rb +2 -0
- data/spec/support/handshake_requests.rb +65 -63
- data/spec/support/incoming_frames.rb +2 -0
- data/spec/support/outgoing_frames.rb +2 -0
- data/spec/support/overwrites.rb +2 -0
- data/websocket.gemspec +2 -2
- metadata +3 -3
@@ -1,9 +1,11 @@
|
|
1
1
|
# encoding: binary
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'spec_helper'
|
4
5
|
|
5
6
|
RSpec.describe 'Incoming frame draft 07' do
|
6
7
|
subject { frame }
|
8
|
+
|
7
9
|
let(:version) { 7 }
|
8
10
|
let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
|
9
11
|
let(:encoded_text) { nil }
|
@@ -11,7 +13,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
11
13
|
let(:frame_type) { nil }
|
12
14
|
let(:error) { nil }
|
13
15
|
|
14
|
-
|
16
|
+
it_behaves_like 'valid_incoming_frame'
|
15
17
|
|
16
18
|
context 'should properly decode close frame' do
|
17
19
|
let(:encoded_text) { "\x88\x07\x03\xE8" + decoded_text }
|
@@ -19,7 +21,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
19
21
|
let(:decoded_text) { 'Hello' }
|
20
22
|
let(:close_code) { 1000 }
|
21
23
|
|
22
|
-
|
24
|
+
it_behaves_like 'valid_incoming_frame'
|
23
25
|
end
|
24
26
|
|
25
27
|
context 'should raise error with invalid close code' do
|
@@ -27,7 +29,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
27
29
|
let(:decoded_text) { nil }
|
28
30
|
let(:error) { WebSocket::Error::Frame::UnknownCloseCode }
|
29
31
|
|
30
|
-
|
32
|
+
it_behaves_like 'valid_incoming_frame'
|
31
33
|
end
|
32
34
|
|
33
35
|
context 'should properly decode close frame with invalid UTF-8 message' do
|
@@ -35,7 +37,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
35
37
|
let(:decoded_text) { nil }
|
36
38
|
let(:error) { WebSocket::Error::Frame::InvalidPayloadEncoding }
|
37
39
|
|
38
|
-
|
40
|
+
it_behaves_like 'valid_incoming_frame'
|
39
41
|
end
|
40
42
|
|
41
43
|
context 'should properly decode ping frame' do
|
@@ -43,7 +45,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
43
45
|
let(:frame_type) { :ping }
|
44
46
|
let(:decoded_text) { 'Hello' }
|
45
47
|
|
46
|
-
|
48
|
+
it_behaves_like 'valid_incoming_frame'
|
47
49
|
end
|
48
50
|
|
49
51
|
context 'should properly decode pong frame' do
|
@@ -51,7 +53,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
51
53
|
let(:frame_type) { :pong }
|
52
54
|
let(:decoded_text) { 'Hello' }
|
53
55
|
|
54
|
-
|
56
|
+
it_behaves_like 'valid_incoming_frame'
|
55
57
|
end
|
56
58
|
|
57
59
|
context 'should properly decode text frame' do
|
@@ -59,7 +61,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
59
61
|
let(:decoded_text) { 'Hello' }
|
60
62
|
let(:frame_type) { :text }
|
61
63
|
|
62
|
-
|
64
|
+
it_behaves_like 'valid_incoming_frame'
|
63
65
|
end
|
64
66
|
|
65
67
|
context 'should properly decode masked text frame' do
|
@@ -67,7 +69,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
67
69
|
let(:decoded_text) { 'Hello' }
|
68
70
|
let(:frame_type) { :text }
|
69
71
|
|
70
|
-
|
72
|
+
it_behaves_like 'valid_incoming_frame'
|
71
73
|
end
|
72
74
|
|
73
75
|
context 'should properly decode text frame with continuation' do
|
@@ -75,7 +77,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
75
77
|
let(:frame_type) { :text }
|
76
78
|
let(:decoded_text) { 'Hello' }
|
77
79
|
|
78
|
-
|
80
|
+
it_behaves_like 'valid_incoming_frame'
|
79
81
|
end
|
80
82
|
|
81
83
|
context 'should properly decode masked text frame with continuation' do
|
@@ -83,15 +85,15 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
83
85
|
let(:frame_type) { :text }
|
84
86
|
let(:decoded_text) { 'Hello' }
|
85
87
|
|
86
|
-
|
88
|
+
it_behaves_like 'valid_incoming_frame'
|
87
89
|
end
|
88
90
|
|
89
91
|
context 'should properly decode text frame in between of continuation' do
|
90
92
|
let(:encoded_text) { "\x01\x03Hel\x8a\x03abc\x80\x02lo" }
|
91
|
-
let(:frame_type) { %i
|
92
|
-
let(:decoded_text) { %w
|
93
|
+
let(:frame_type) { %i[pong text] }
|
94
|
+
let(:decoded_text) { %w[abc Hello] }
|
93
95
|
|
94
|
-
|
96
|
+
it_behaves_like 'valid_incoming_frame'
|
95
97
|
end
|
96
98
|
|
97
99
|
context 'should not return unfinished more frame' do
|
@@ -99,7 +101,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
99
101
|
let(:frame_type) { :pong }
|
100
102
|
let(:decoded_text) { 'abc' }
|
101
103
|
|
102
|
-
|
104
|
+
it_behaves_like 'valid_incoming_frame'
|
103
105
|
end
|
104
106
|
|
105
107
|
context 'should properly decode 256 bytes binary frame' do
|
@@ -107,7 +109,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
107
109
|
let(:frame_type) { :binary }
|
108
110
|
let(:decoded_text) { 'a' * 256 }
|
109
111
|
|
110
|
-
|
112
|
+
it_behaves_like 'valid_incoming_frame'
|
111
113
|
end
|
112
114
|
|
113
115
|
context 'should properly decode 64KiB binary frame' do
|
@@ -115,14 +117,14 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
115
117
|
let(:frame_type) { :binary }
|
116
118
|
let(:decoded_text) { 'a' * 65_536 }
|
117
119
|
|
118
|
-
|
120
|
+
it_behaves_like 'valid_incoming_frame'
|
119
121
|
end
|
120
122
|
|
121
123
|
context 'should wait with incomplete frame' do
|
122
124
|
let(:encoded_text) { "\x81\x06Hello" }
|
123
125
|
let(:decoded_text) { nil }
|
124
126
|
|
125
|
-
|
127
|
+
it_behaves_like 'valid_incoming_frame'
|
126
128
|
end
|
127
129
|
|
128
130
|
context 'should raise error with invalid opcode' do
|
@@ -130,7 +132,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
130
132
|
let(:decoded_text) { nil }
|
131
133
|
let(:error) { WebSocket::Error::Frame::UnknownOpcode }
|
132
134
|
|
133
|
-
|
135
|
+
it_behaves_like 'valid_incoming_frame'
|
134
136
|
end
|
135
137
|
|
136
138
|
context 'should raise error with too long frame' do
|
@@ -138,7 +140,7 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
138
140
|
let(:decoded_text) { nil }
|
139
141
|
let(:error) { WebSocket::Error::Frame::TooLong }
|
140
142
|
|
141
|
-
|
143
|
+
it_behaves_like 'valid_incoming_frame'
|
142
144
|
end
|
143
145
|
|
144
146
|
context 'should raise error with continuation frame without more frame earlier' do
|
@@ -146,6 +148,6 @@ RSpec.describe 'Incoming frame draft 07' do
|
|
146
148
|
let(:decoded_text) { nil }
|
147
149
|
let(:error) { WebSocket::Error::Frame::UnexpectedContinuationFrame }
|
148
150
|
|
149
|
-
|
151
|
+
it_behaves_like 'valid_incoming_frame'
|
150
152
|
end
|
151
153
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# encoding: binary
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'spec_helper'
|
4
5
|
|
5
6
|
RSpec.describe 'Incoming frame draft 75' do
|
6
7
|
subject { frame }
|
8
|
+
|
7
9
|
let(:version) { 75 }
|
8
10
|
let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
|
9
11
|
let(:encoded_text) { nil }
|
@@ -11,22 +13,22 @@ RSpec.describe 'Incoming frame draft 75' do
|
|
11
13
|
let(:frame_type) { nil }
|
12
14
|
let(:error) { nil }
|
13
15
|
|
14
|
-
|
16
|
+
it_behaves_like 'valid_incoming_frame'
|
15
17
|
|
16
18
|
context 'with valid text frame' do
|
17
19
|
let(:encoded_text) { "\x00abc\xFF" }
|
18
20
|
let(:decoded_text) { 'abc' }
|
19
21
|
let(:frame_type) { :text }
|
20
22
|
|
21
|
-
|
23
|
+
it_behaves_like 'valid_incoming_frame'
|
22
24
|
end
|
23
25
|
|
24
26
|
context 'with two frames' do
|
25
27
|
let(:encoded_text) { "\x00abc\xFF\x00def\xFF" }
|
26
|
-
let(:decoded_text) { %w
|
27
|
-
let(:frame_type) { %i
|
28
|
+
let(:decoded_text) { %w[abc def] }
|
29
|
+
let(:frame_type) { %i[text text] }
|
28
30
|
|
29
|
-
|
31
|
+
it_behaves_like 'valid_incoming_frame'
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'with close frame' do
|
@@ -34,27 +36,27 @@ RSpec.describe 'Incoming frame draft 75' do
|
|
34
36
|
let(:decoded_text) { '' }
|
35
37
|
let(:frame_type) { :close }
|
36
38
|
|
37
|
-
|
39
|
+
it_behaves_like 'valid_incoming_frame'
|
38
40
|
end
|
39
41
|
|
40
42
|
context 'with incomplete frame' do
|
41
43
|
let(:encoded_text) { "\x00test" }
|
42
44
|
let(:decoded_text) { nil }
|
43
45
|
|
44
|
-
|
46
|
+
it_behaves_like 'valid_incoming_frame'
|
45
47
|
end
|
46
48
|
|
47
49
|
context 'with invalid frame' do
|
48
50
|
let(:encoded_text) { 'invalid' }
|
49
51
|
let(:error) { WebSocket::Error::Frame::Invalid }
|
50
52
|
|
51
|
-
|
53
|
+
it_behaves_like 'valid_incoming_frame'
|
52
54
|
end
|
53
55
|
|
54
56
|
context 'with too long frame' do
|
55
57
|
let(:encoded_text) { "\x00" + 'a' * WebSocket.max_frame_size + "\xFF" }
|
56
58
|
let(:error) { WebSocket::Error::Frame::TooLong }
|
57
59
|
|
58
|
-
|
60
|
+
it_behaves_like 'valid_incoming_frame'
|
59
61
|
end
|
60
62
|
end
|
data/spec/frame/masking_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# encoding: binary
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'spec_helper'
|
4
5
|
|
5
6
|
RSpec.describe 'Outgoing frame draft 03' do
|
6
7
|
subject { frame }
|
8
|
+
|
7
9
|
let(:version) { 3 }
|
8
10
|
let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
|
9
11
|
let(:decoded_text) { '' }
|
@@ -12,7 +14,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
12
14
|
let(:require_sending) { true }
|
13
15
|
let(:error) { nil }
|
14
16
|
|
15
|
-
|
17
|
+
it_behaves_like 'valid_outgoing_frame'
|
16
18
|
|
17
19
|
context 'should properly encode close frame' do
|
18
20
|
let(:frame_type) { :close }
|
@@ -20,7 +22,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
20
22
|
let(:encoded_text) { "\x01\x05" + decoded_text }
|
21
23
|
let(:require_sending) { true }
|
22
24
|
|
23
|
-
|
25
|
+
it_behaves_like 'valid_outgoing_frame'
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'should properly encode ping frame' do
|
@@ -29,7 +31,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
29
31
|
let(:encoded_text) { "\x02\x05" + decoded_text }
|
30
32
|
let(:require_sending) { true }
|
31
33
|
|
32
|
-
|
34
|
+
it_behaves_like 'valid_outgoing_frame'
|
33
35
|
end
|
34
36
|
|
35
37
|
context 'should properly encode pong frame' do
|
@@ -38,7 +40,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
38
40
|
let(:encoded_text) { "\x03\x05" + decoded_text }
|
39
41
|
let(:require_sending) { true }
|
40
42
|
|
41
|
-
|
43
|
+
it_behaves_like 'valid_outgoing_frame'
|
42
44
|
end
|
43
45
|
|
44
46
|
context 'should properly encode text frame' do
|
@@ -46,7 +48,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
46
48
|
let(:encoded_text) { "\x04\x05" + decoded_text }
|
47
49
|
let(:require_sending) { true }
|
48
50
|
|
49
|
-
|
51
|
+
it_behaves_like 'valid_outgoing_frame'
|
50
52
|
end
|
51
53
|
|
52
54
|
context 'should properly encode 256 bytes binary frame' do
|
@@ -55,7 +57,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
55
57
|
let(:encoded_text) { "\x05\x7E\x01\x00" + decoded_text }
|
56
58
|
let(:require_sending) { true }
|
57
59
|
|
58
|
-
|
60
|
+
it_behaves_like 'valid_outgoing_frame'
|
59
61
|
end
|
60
62
|
|
61
63
|
context 'should properly encode 64KiB binary frame' do
|
@@ -64,7 +66,7 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
64
66
|
let(:encoded_text) { "\x05\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
65
67
|
let(:require_sending) { true }
|
66
68
|
|
67
|
-
|
69
|
+
it_behaves_like 'valid_outgoing_frame'
|
68
70
|
end
|
69
71
|
|
70
72
|
context 'should return error for unknown frame type' do
|
@@ -74,6 +76,6 @@ RSpec.describe 'Outgoing frame draft 03' do
|
|
74
76
|
let(:error) { :unknown_frame_type }
|
75
77
|
let(:require_sending) { false }
|
76
78
|
|
77
|
-
|
79
|
+
it_behaves_like 'valid_outgoing_frame'
|
78
80
|
end
|
79
81
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# encoding: binary
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'spec_helper'
|
4
5
|
|
5
6
|
RSpec.describe 'Outgoing frame draft 04' do
|
6
7
|
subject { frame }
|
8
|
+
|
7
9
|
let(:version) { 4 }
|
8
10
|
let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
|
9
11
|
let(:decoded_text) { '' }
|
@@ -12,7 +14,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
12
14
|
let(:require_sending) { true }
|
13
15
|
let(:error) { nil }
|
14
16
|
|
15
|
-
|
17
|
+
it_behaves_like 'valid_outgoing_frame'
|
16
18
|
|
17
19
|
context 'should properly encode close frame' do
|
18
20
|
let(:frame_type) { :close }
|
@@ -20,7 +22,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
20
22
|
let(:encoded_text) { "\x81\x05" + decoded_text }
|
21
23
|
let(:require_sending) { true }
|
22
24
|
|
23
|
-
|
25
|
+
it_behaves_like 'valid_outgoing_frame'
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'should properly encode ping frame' do
|
@@ -29,7 +31,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
29
31
|
let(:encoded_text) { "\x82\x05" + decoded_text }
|
30
32
|
let(:require_sending) { true }
|
31
33
|
|
32
|
-
|
34
|
+
it_behaves_like 'valid_outgoing_frame'
|
33
35
|
end
|
34
36
|
|
35
37
|
context 'should properly encode pong frame' do
|
@@ -38,7 +40,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
38
40
|
let(:encoded_text) { "\x83\x05" + decoded_text }
|
39
41
|
let(:require_sending) { true }
|
40
42
|
|
41
|
-
|
43
|
+
it_behaves_like 'valid_outgoing_frame'
|
42
44
|
end
|
43
45
|
|
44
46
|
context 'should properly encode text frame' do
|
@@ -46,7 +48,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
46
48
|
let(:encoded_text) { "\x84\x05" + decoded_text }
|
47
49
|
let(:require_sending) { true }
|
48
50
|
|
49
|
-
|
51
|
+
it_behaves_like 'valid_outgoing_frame'
|
50
52
|
end
|
51
53
|
|
52
54
|
context 'should properly encode 256 bytes binary frame' do
|
@@ -55,7 +57,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
55
57
|
let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
|
56
58
|
let(:require_sending) { true }
|
57
59
|
|
58
|
-
|
60
|
+
it_behaves_like 'valid_outgoing_frame'
|
59
61
|
end
|
60
62
|
|
61
63
|
context 'should properly encode 64KiB binary frame' do
|
@@ -64,7 +66,7 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
64
66
|
let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
65
67
|
let(:require_sending) { true }
|
66
68
|
|
67
|
-
|
69
|
+
it_behaves_like 'valid_outgoing_frame'
|
68
70
|
end
|
69
71
|
|
70
72
|
context 'should return error for unknown frame type' do
|
@@ -74,6 +76,6 @@ RSpec.describe 'Outgoing frame draft 04' do
|
|
74
76
|
let(:error) { :unknown_frame_type }
|
75
77
|
let(:require_sending) { false }
|
76
78
|
|
77
|
-
|
79
|
+
it_behaves_like 'valid_outgoing_frame'
|
78
80
|
end
|
79
81
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# encoding: binary
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'spec_helper'
|
4
5
|
|
5
6
|
RSpec.describe 'Outgoing frame draft 05' do
|
6
7
|
subject { frame }
|
8
|
+
|
7
9
|
let(:version) { 5 }
|
8
10
|
let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
|
9
11
|
let(:decoded_text) { '' }
|
@@ -12,7 +14,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
12
14
|
let(:require_sending) { true }
|
13
15
|
let(:error) { nil }
|
14
16
|
|
15
|
-
|
17
|
+
it_behaves_like 'valid_outgoing_frame'
|
16
18
|
|
17
19
|
context 'should properly encode close frame' do
|
18
20
|
let(:frame_type) { :close }
|
@@ -20,7 +22,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
20
22
|
let(:encoded_text) { "\x81\x05" + decoded_text }
|
21
23
|
let(:require_sending) { true }
|
22
24
|
|
23
|
-
|
25
|
+
it_behaves_like 'valid_outgoing_frame'
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'should properly encode ping frame' do
|
@@ -29,7 +31,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
29
31
|
let(:encoded_text) { "\x82\x05" + decoded_text }
|
30
32
|
let(:require_sending) { true }
|
31
33
|
|
32
|
-
|
34
|
+
it_behaves_like 'valid_outgoing_frame'
|
33
35
|
end
|
34
36
|
|
35
37
|
context 'should properly encode pong frame' do
|
@@ -38,7 +40,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
38
40
|
let(:encoded_text) { "\x83\x05" + decoded_text }
|
39
41
|
let(:require_sending) { true }
|
40
42
|
|
41
|
-
|
43
|
+
it_behaves_like 'valid_outgoing_frame'
|
42
44
|
end
|
43
45
|
|
44
46
|
context 'should properly encode text frame' do
|
@@ -46,7 +48,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
46
48
|
let(:encoded_text) { "\x84\x05" + decoded_text }
|
47
49
|
let(:require_sending) { true }
|
48
50
|
|
49
|
-
|
51
|
+
it_behaves_like 'valid_outgoing_frame'
|
50
52
|
end
|
51
53
|
|
52
54
|
context 'should properly encode 256 bytes binary frame' do
|
@@ -55,7 +57,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
55
57
|
let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
|
56
58
|
let(:require_sending) { true }
|
57
59
|
|
58
|
-
|
60
|
+
it_behaves_like 'valid_outgoing_frame'
|
59
61
|
end
|
60
62
|
|
61
63
|
context 'should properly encode 64KiB binary frame' do
|
@@ -64,7 +66,7 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
64
66
|
let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
65
67
|
let(:require_sending) { true }
|
66
68
|
|
67
|
-
|
69
|
+
it_behaves_like 'valid_outgoing_frame'
|
68
70
|
end
|
69
71
|
|
70
72
|
context 'should return error for unknown frame type' do
|
@@ -74,6 +76,6 @@ RSpec.describe 'Outgoing frame draft 05' do
|
|
74
76
|
let(:error) { :unknown_frame_type }
|
75
77
|
let(:require_sending) { false }
|
76
78
|
|
77
|
-
|
79
|
+
it_behaves_like 'valid_outgoing_frame'
|
78
80
|
end
|
79
81
|
end
|