websocket 1.1.4 → 1.2.0

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.
Files changed (55) hide show
  1. data/.travis.yml +2 -6
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile +2 -1
  4. data/README.md +10 -6
  5. data/Rakefile +1 -1
  6. data/lib/websocket.rb +1 -1
  7. data/lib/websocket/exception_handler.rb +6 -0
  8. data/lib/websocket/frame/base.rb +1 -1
  9. data/lib/websocket/frame/data.rb +11 -9
  10. data/lib/websocket/frame/handler.rb +1 -1
  11. data/lib/websocket/frame/handler/handler03.rb +17 -17
  12. data/lib/websocket/frame/handler/handler07.rb +8 -8
  13. data/lib/websocket/frame/handler/handler75.rb +8 -7
  14. data/lib/websocket/frame/incoming.rb +1 -1
  15. data/lib/websocket/frame/outgoing.rb +1 -1
  16. data/lib/websocket/handshake/base.rb +7 -7
  17. data/lib/websocket/handshake/client.rb +5 -3
  18. data/lib/websocket/handshake/handler/base.rb +5 -5
  19. data/lib/websocket/handshake/handler/client.rb +6 -1
  20. data/lib/websocket/handshake/handler/client04.rb +7 -6
  21. data/lib/websocket/handshake/handler/client75.rb +5 -4
  22. data/lib/websocket/handshake/handler/client76.rb +5 -5
  23. data/lib/websocket/handshake/handler/server04.rb +11 -6
  24. data/lib/websocket/handshake/handler/server75.rb +5 -5
  25. data/lib/websocket/handshake/handler/server76.rb +9 -9
  26. data/lib/websocket/handshake/server.rb +25 -24
  27. data/lib/websocket/version.rb +1 -1
  28. data/spec/frame/incoming_03_spec.rb +25 -25
  29. data/spec/frame/incoming_04_spec.rb +25 -25
  30. data/spec/frame/incoming_05_spec.rb +29 -29
  31. data/spec/frame/incoming_07_spec.rb +31 -31
  32. data/spec/frame/incoming_75_spec.rb +13 -13
  33. data/spec/frame/incoming_common_spec.rb +12 -13
  34. data/spec/frame/masking_spec.rb +10 -10
  35. data/spec/frame/outgoing_03_spec.rb +17 -17
  36. data/spec/frame/outgoing_04_spec.rb +17 -17
  37. data/spec/frame/outgoing_05_spec.rb +17 -17
  38. data/spec/frame/outgoing_07_spec.rb +19 -19
  39. data/spec/frame/outgoing_75_spec.rb +9 -9
  40. data/spec/frame/outgoing_common_spec.rb +7 -8
  41. data/spec/handshake/client_04_spec.rb +9 -9
  42. data/spec/handshake/client_75_spec.rb +2 -2
  43. data/spec/handshake/client_76_spec.rb +9 -9
  44. data/spec/handshake/server_04_spec.rb +5 -5
  45. data/spec/handshake/server_75_spec.rb +1 -1
  46. data/spec/handshake/server_76_spec.rb +21 -21
  47. data/spec/spec_helper.rb +4 -1
  48. data/spec/support/all_client_drafts.rb +62 -52
  49. data/spec/support/all_server_drafts.rb +49 -49
  50. data/spec/support/handshake_requests.rb +16 -16
  51. data/spec/support/incoming_frames.rb +28 -28
  52. data/spec/support/outgoing_frames.rb +10 -10
  53. data/websocket.gemspec +1 -1
  54. metadata +42 -22
  55. checksums.yaml +0 -7
@@ -1,9 +1,9 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Incoming frame draft 75' do
4
+ RSpec.describe 'Incoming frame draft 75' do
5
5
  let(:version) { 75 }
6
- let(:frame) { WebSocket::Frame::Incoming.new(:version => version, :data => encoded_text) }
6
+ let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
7
7
  let(:encoded_text) { nil }
8
8
  let(:decoded_text) { nil }
9
9
  let(:frame_type) { nil }
@@ -12,46 +12,46 @@ describe 'Incoming frame draft 75' do
12
12
 
13
13
  it_should_behave_like 'valid_incoming_frame'
14
14
 
15
- context "with valid text frame" do
15
+ context 'with valid text frame' do
16
16
  let(:encoded_text) { "\x00abc\xFF" }
17
- let(:decoded_text) { "abc" }
17
+ let(:decoded_text) { 'abc' }
18
18
  let(:frame_type) { :text }
19
19
 
20
20
  it_should_behave_like 'valid_incoming_frame'
21
21
  end
22
22
 
23
- context "with two frames" do
23
+ context 'with two frames' do
24
24
  let(:encoded_text) { "\x00abc\xFF\x00def\xFF" }
25
- let(:decoded_text) { ["abc", "def"] }
25
+ let(:decoded_text) { ['abc', 'def'] }
26
26
  let(:frame_type) { [:text, :text] }
27
27
 
28
28
  it_should_behave_like 'valid_incoming_frame'
29
29
  end
30
30
 
31
- context "with close frame" do
31
+ context 'with close frame' do
32
32
  let(:encoded_text) { "\xFF\x00" }
33
- let(:decoded_text) { "" }
33
+ let(:decoded_text) { '' }
34
34
  let(:frame_type) { :close }
35
35
 
36
36
  it_should_behave_like 'valid_incoming_frame'
37
37
  end
38
38
 
39
- context "with incomplete frame" do
39
+ context 'with incomplete frame' do
40
40
  let(:encoded_text) { "\x00test" }
41
41
  let(:decoded_text) { nil }
42
42
 
43
43
  it_should_behave_like 'valid_incoming_frame'
44
44
  end
45
45
 
46
- context "with invalid frame" do
47
- let(:encoded_text) { "invalid" }
46
+ context 'with invalid frame' do
47
+ let(:encoded_text) { 'invalid' }
48
48
  let(:error) { WebSocket::Error::Frame::Invalid }
49
49
 
50
50
  it_should_behave_like 'valid_incoming_frame'
51
51
  end
52
52
 
53
- context "with too long frame" do
54
- let(:encoded_text) { "\x00" + "a" * WebSocket.max_frame_size + "\xFF" }
53
+ context 'with too long frame' do
54
+ let(:encoded_text) { "\x00" + 'a' * WebSocket.max_frame_size + "\xFF" }
55
55
  let(:error) { WebSocket::Error::Frame::TooLong }
56
56
 
57
57
  it_should_behave_like 'valid_incoming_frame'
@@ -1,23 +1,22 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Incoming common frame' do
4
+ RSpec.describe 'Incoming common frame' do
5
5
  subject { WebSocket::Frame::Incoming.new }
6
6
 
7
- its(:version) { should eql(13) }
8
- its(:decoded?) { should be_false }
9
- # Not implemented yet
10
- # its(:error?) { should be_false }
7
+ its(:version) { is_expected.to eql(13) }
8
+ its(:decoded?) { is_expected.to be false }
9
+ its(:error?) { is_expected.to be false }
11
10
 
12
- it "should allow adding data via <<" do
13
- subject.data.should eql("")
14
- subject << "test"
15
- subject.data.should eql("test")
11
+ it 'should allow adding data via <<' do
12
+ expect(subject.data).to eql('')
13
+ subject << 'test'
14
+ expect(subject.data).to eql('test')
16
15
  end
17
16
 
18
- it "should raise error on invalid version" do
19
- subject = WebSocket::Frame::Incoming.new(:version => 70)
20
- subject.error?.should be_true
21
- subject.error.should eql(:unknown_protocol_version)
17
+ it 'should raise error on invalid version' do
18
+ subject = WebSocket::Frame::Incoming.new(version: 70)
19
+ expect(subject.error?).to be true
20
+ expect(subject.error).to eql(:unknown_protocol_version)
22
21
  end
23
22
  end
@@ -1,16 +1,16 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Masking frame draft 07' do
5
- it "should encode and decode masked frame correctly" do
6
- outgoing_frame = WebSocket::Frame::Outgoing::Client.new(:data => "Hello World", :type => "text")
4
+ RSpec.describe 'Masking frame draft 07' do
5
+ it 'should encode and decode masked frame correctly' do
6
+ outgoing_frame = WebSocket::Frame::Outgoing::Client.new(data: 'Hello World', type: 'text')
7
7
  outgoing_frame.to_s
8
- outgoing_frame.error.should be_nil
9
- incoming_frame = WebSocket::Frame::Incoming::Server.new(:data => outgoing_frame.to_s).next
10
- incoming_frame.should_not be_nil
11
- incoming_frame.class.should eql(WebSocket::Frame::Incoming::Server)
12
- incoming_frame.error.should be_nil
13
- incoming_frame.decoded?.should be_true
14
- incoming_frame.to_s.should eql('Hello World')
8
+ expect(outgoing_frame.error).to be_nil
9
+ incoming_frame = WebSocket::Frame::Incoming::Server.new(data: outgoing_frame.to_s).next
10
+ expect(incoming_frame).not_to be_nil
11
+ expect(incoming_frame.class).to eql(WebSocket::Frame::Incoming::Server)
12
+ expect(incoming_frame.error).to be_nil
13
+ expect(incoming_frame.decoded?).to be true
14
+ expect(incoming_frame.to_s).to eql('Hello World')
15
15
  end
16
16
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Outgoing frame draft 03' do
4
+ RSpec.describe 'Outgoing frame draft 03' do
5
5
  let(:version) { 03 }
6
- let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type) }
7
- let(:decoded_text) { "" }
6
+ let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
7
+ let(:decoded_text) { '' }
8
8
  let(:encoded_text) { "\x04\x00" }
9
9
  let(:frame_type) { :text }
10
10
  let(:require_sending) { true }
@@ -13,62 +13,62 @@ describe 'Outgoing frame draft 03' do
13
13
 
14
14
  it_should_behave_like 'valid_outgoing_frame'
15
15
 
16
- context "should properly encode close frame" do
16
+ context 'should properly encode close frame' do
17
17
  let(:frame_type) { :close }
18
- let(:decoded_text) { "Hello" }
18
+ let(:decoded_text) { 'Hello' }
19
19
  let(:encoded_text) { "\x01\x05" + decoded_text }
20
20
  let(:require_sending) { true }
21
21
 
22
22
  it_should_behave_like 'valid_outgoing_frame'
23
23
  end
24
24
 
25
- context "should properly encode ping frame" do
25
+ context 'should properly encode ping frame' do
26
26
  let(:frame_type) { :ping }
27
- let(:decoded_text) { "Hello" }
27
+ let(:decoded_text) { 'Hello' }
28
28
  let(:encoded_text) { "\x02\x05" + decoded_text }
29
29
  let(:require_sending) { true }
30
30
 
31
31
  it_should_behave_like 'valid_outgoing_frame'
32
32
  end
33
33
 
34
- context "should properly encode pong frame" do
34
+ context 'should properly encode pong frame' do
35
35
  let(:frame_type) { :pong }
36
- let(:decoded_text) { "Hello" }
36
+ let(:decoded_text) { 'Hello' }
37
37
  let(:encoded_text) { "\x03\x05" + decoded_text }
38
38
  let(:require_sending) { true }
39
39
 
40
40
  it_should_behave_like 'valid_outgoing_frame'
41
41
  end
42
42
 
43
- context "should properly encode text frame" do
44
- let(:decoded_text) { "Hello" }
43
+ context 'should properly encode text frame' do
44
+ let(:decoded_text) { 'Hello' }
45
45
  let(:encoded_text) { "\x04\x05" + decoded_text }
46
46
  let(:require_sending) { true }
47
47
 
48
48
  it_should_behave_like 'valid_outgoing_frame'
49
49
  end
50
50
 
51
- context "should properly encode 256 bytes binary frame" do
51
+ context 'should properly encode 256 bytes binary frame' do
52
52
  let(:frame_type) { :binary }
53
- let(:decoded_text) { "a" * 256 }
53
+ let(:decoded_text) { 'a' * 256 }
54
54
  let(:encoded_text) { "\x05\x7E\x01\x00" + decoded_text }
55
55
  let(:require_sending) { true }
56
56
 
57
57
  it_should_behave_like 'valid_outgoing_frame'
58
58
  end
59
59
 
60
- context "should properly encode 64KiB binary frame" do
60
+ context 'should properly encode 64KiB binary frame' do
61
61
  let(:frame_type) { :binary }
62
- let(:decoded_text) { "a" * 65536 }
62
+ let(:decoded_text) { 'a' * 65_536 }
63
63
  let(:encoded_text) { "\x05\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
64
64
  let(:require_sending) { true }
65
65
 
66
66
  it_should_behave_like 'valid_outgoing_frame'
67
67
  end
68
68
 
69
- context "should return error for unknown frame type" do
69
+ context 'should return error for unknown frame type' do
70
70
  let(:frame_type) { :unknown }
71
- let(:decoded_text) { "Hello" }
71
+ let(:decoded_text) { 'Hello' }
72
72
  let(:encoded_text) { nil }
73
73
  let(:error) { :unknown_frame_type }
74
74
  let(:require_sending) { false }
@@ -1,10 +1,10 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Outgoing frame draft 04' do
4
+ RSpec.describe 'Outgoing frame draft 04' do
5
5
  let(:version) { 04 }
6
- let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type) }
7
- let(:decoded_text) { "" }
6
+ let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
7
+ let(:decoded_text) { '' }
8
8
  let(:encoded_text) { "\x84\x00" }
9
9
  let(:frame_type) { :text }
10
10
  let(:require_sending) { true }
@@ -13,62 +13,62 @@ describe 'Outgoing frame draft 04' do
13
13
 
14
14
  it_should_behave_like 'valid_outgoing_frame'
15
15
 
16
- context "should properly encode close frame" do
16
+ context 'should properly encode close frame' do
17
17
  let(:frame_type) { :close }
18
- let(:decoded_text) { "Hello" }
18
+ let(:decoded_text) { 'Hello' }
19
19
  let(:encoded_text) { "\x81\x05" + decoded_text }
20
20
  let(:require_sending) { true }
21
21
 
22
22
  it_should_behave_like 'valid_outgoing_frame'
23
23
  end
24
24
 
25
- context "should properly encode ping frame" do
25
+ context 'should properly encode ping frame' do
26
26
  let(:frame_type) { :ping }
27
- let(:decoded_text) { "Hello" }
27
+ let(:decoded_text) { 'Hello' }
28
28
  let(:encoded_text) { "\x82\x05" + decoded_text }
29
29
  let(:require_sending) { true }
30
30
 
31
31
  it_should_behave_like 'valid_outgoing_frame'
32
32
  end
33
33
 
34
- context "should properly encode pong frame" do
34
+ context 'should properly encode pong frame' do
35
35
  let(:frame_type) { :pong }
36
- let(:decoded_text) { "Hello" }
36
+ let(:decoded_text) { 'Hello' }
37
37
  let(:encoded_text) { "\x83\x05" + decoded_text }
38
38
  let(:require_sending) { true }
39
39
 
40
40
  it_should_behave_like 'valid_outgoing_frame'
41
41
  end
42
42
 
43
- context "should properly encode text frame" do
44
- let(:decoded_text) { "Hello" }
43
+ context 'should properly encode text frame' do
44
+ let(:decoded_text) { 'Hello' }
45
45
  let(:encoded_text) { "\x84\x05" + decoded_text }
46
46
  let(:require_sending) { true }
47
47
 
48
48
  it_should_behave_like 'valid_outgoing_frame'
49
49
  end
50
50
 
51
- context "should properly encode 256 bytes binary frame" do
51
+ context 'should properly encode 256 bytes binary frame' do
52
52
  let(:frame_type) { :binary }
53
- let(:decoded_text) { "a" * 256 }
53
+ let(:decoded_text) { 'a' * 256 }
54
54
  let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
55
55
  let(:require_sending) { true }
56
56
 
57
57
  it_should_behave_like 'valid_outgoing_frame'
58
58
  end
59
59
 
60
- context "should properly encode 64KiB binary frame" do
60
+ context 'should properly encode 64KiB binary frame' do
61
61
  let(:frame_type) { :binary }
62
- let(:decoded_text) { "a" * 65536 }
62
+ let(:decoded_text) { 'a' * 65_536 }
63
63
  let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
64
64
  let(:require_sending) { true }
65
65
 
66
66
  it_should_behave_like 'valid_outgoing_frame'
67
67
  end
68
68
 
69
- context "should return error for unknown frame type" do
69
+ context 'should return error for unknown frame type' do
70
70
  let(:frame_type) { :unknown }
71
- let(:decoded_text) { "Hello" }
71
+ let(:decoded_text) { 'Hello' }
72
72
  let(:encoded_text) { nil }
73
73
  let(:error) { :unknown_frame_type }
74
74
  let(:require_sending) { false }
@@ -1,10 +1,10 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Outgoing frame draft 05' do
4
+ RSpec.describe 'Outgoing frame draft 05' do
5
5
  let(:version) { 5 }
6
- let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type) }
7
- let(:decoded_text) { "" }
6
+ let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type) }
7
+ let(:decoded_text) { '' }
8
8
  let(:encoded_text) { "\x84\x00" }
9
9
  let(:frame_type) { :text }
10
10
  let(:require_sending) { true }
@@ -13,62 +13,62 @@ describe 'Outgoing frame draft 05' do
13
13
 
14
14
  it_should_behave_like 'valid_outgoing_frame'
15
15
 
16
- context "should properly encode close frame" do
16
+ context 'should properly encode close frame' do
17
17
  let(:frame_type) { :close }
18
- let(:decoded_text) { "Hello" }
18
+ let(:decoded_text) { 'Hello' }
19
19
  let(:encoded_text) { "\x81\x05" + decoded_text }
20
20
  let(:require_sending) { true }
21
21
 
22
22
  it_should_behave_like 'valid_outgoing_frame'
23
23
  end
24
24
 
25
- context "should properly encode ping frame" do
25
+ context 'should properly encode ping frame' do
26
26
  let(:frame_type) { :ping }
27
- let(:decoded_text) { "Hello" }
27
+ let(:decoded_text) { 'Hello' }
28
28
  let(:encoded_text) { "\x82\x05" + decoded_text }
29
29
  let(:require_sending) { true }
30
30
 
31
31
  it_should_behave_like 'valid_outgoing_frame'
32
32
  end
33
33
 
34
- context "should properly encode pong frame" do
34
+ context 'should properly encode pong frame' do
35
35
  let(:frame_type) { :pong }
36
- let(:decoded_text) { "Hello" }
36
+ let(:decoded_text) { 'Hello' }
37
37
  let(:encoded_text) { "\x83\x05" + decoded_text }
38
38
  let(:require_sending) { true }
39
39
 
40
40
  it_should_behave_like 'valid_outgoing_frame'
41
41
  end
42
42
 
43
- context "should properly encode text frame" do
44
- let(:decoded_text) { "Hello" }
43
+ context 'should properly encode text frame' do
44
+ let(:decoded_text) { 'Hello' }
45
45
  let(:encoded_text) { "\x84\x05" + decoded_text }
46
46
  let(:require_sending) { true }
47
47
 
48
48
  it_should_behave_like 'valid_outgoing_frame'
49
49
  end
50
50
 
51
- context "should properly encode 256 bytes binary frame" do
51
+ context 'should properly encode 256 bytes binary frame' do
52
52
  let(:frame_type) { :binary }
53
- let(:decoded_text) { "a" * 256 }
53
+ let(:decoded_text) { 'a' * 256 }
54
54
  let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
55
55
  let(:require_sending) { true }
56
56
 
57
57
  it_should_behave_like 'valid_outgoing_frame'
58
58
  end
59
59
 
60
- context "should properly encode 64KiB binary frame" do
60
+ context 'should properly encode 64KiB binary frame' do
61
61
  let(:frame_type) { :binary }
62
- let(:decoded_text) { "a" * 65536 }
62
+ let(:decoded_text) { 'a' * 65_536 }
63
63
  let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
64
64
  let(:require_sending) { true }
65
65
 
66
66
  it_should_behave_like 'valid_outgoing_frame'
67
67
  end
68
68
 
69
- context "should return error for unknown frame type" do
69
+ context 'should return error for unknown frame type' do
70
70
  let(:frame_type) { :unknown }
71
- let(:decoded_text) { "Hello" }
71
+ let(:decoded_text) { 'Hello' }
72
72
  let(:encoded_text) { nil }
73
73
  let(:error) { :unknown_frame_type }
74
74
  let(:require_sending) { false }
@@ -1,10 +1,10 @@
1
1
  # encoding: binary
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Outgoing frame draft 07' do
4
+ RSpec.describe 'Outgoing frame draft 07' do
5
5
  let(:version) { 7 }
6
- let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type, :code => close_code) }
7
- let(:decoded_text) { "" }
6
+ let(:frame) { WebSocket::Frame::Outgoing.new(version: version, data: decoded_text, type: frame_type, code: close_code) }
7
+ let(:decoded_text) { '' }
8
8
  let(:close_code) { nil }
9
9
  let(:encoded_text) { "\x81\x00" }
10
10
  let(:frame_type) { :text }
@@ -14,18 +14,18 @@ describe 'Outgoing frame draft 07' do
14
14
 
15
15
  it_should_behave_like 'valid_outgoing_frame'
16
16
 
17
- context "should properly encode close frame without close code" do
17
+ context 'should properly encode close frame without close code' do
18
18
  let(:frame_type) { :close }
19
- let(:decoded_text) { "Hello" }
19
+ let(:decoded_text) { 'Hello' }
20
20
  let(:encoded_text) { "\x88\x07\x03\xE8" + decoded_text }
21
21
  let(:require_sending) { true }
22
22
 
23
23
  it_should_behave_like 'valid_outgoing_frame'
24
24
  end
25
25
 
26
- context "should properly encode close frame with close code" do
26
+ context 'should properly encode close frame with close code' do
27
27
  let(:frame_type) { :close }
28
- let(:decoded_text) { "Hello" }
28
+ let(:decoded_text) { 'Hello' }
29
29
  let(:close_code) { 1001 }
30
30
  let(:encoded_text) { "\x88\x07\x03\xE9" + decoded_text }
31
31
  let(:require_sending) { true }
@@ -33,53 +33,53 @@ describe 'Outgoing frame draft 07' do
33
33
  it_should_behave_like 'valid_outgoing_frame'
34
34
  end
35
35
 
36
- context "should properly encode ping frame" do
36
+ context 'should properly encode ping frame' do
37
37
  let(:frame_type) { :ping }
38
- let(:decoded_text) { "Hello" }
38
+ let(:decoded_text) { 'Hello' }
39
39
  let(:encoded_text) { "\x89\x05" + decoded_text }
40
40
  let(:require_sending) { true }
41
41
 
42
42
  it_should_behave_like 'valid_outgoing_frame'
43
43
  end
44
44
 
45
- context "should properly encode pong frame" do
45
+ context 'should properly encode pong frame' do
46
46
  let(:frame_type) { :pong }
47
- let(:decoded_text) { "Hello" }
47
+ let(:decoded_text) { 'Hello' }
48
48
  let(:encoded_text) { "\x8a\x05" + decoded_text }
49
49
  let(:require_sending) { true }
50
50
 
51
51
  it_should_behave_like 'valid_outgoing_frame'
52
52
  end
53
53
 
54
- context "should properly encode text frame" do
55
- let(:decoded_text) { "Hello" }
54
+ context 'should properly encode text frame' do
55
+ let(:decoded_text) { 'Hello' }
56
56
  let(:encoded_text) { "\x81\x05" + decoded_text }
57
57
  let(:require_sending) { true }
58
58
 
59
59
  it_should_behave_like 'valid_outgoing_frame'
60
60
  end
61
61
 
62
- context "should properly encode 256 bytes binary frame" do
62
+ context 'should properly encode 256 bytes binary frame' do
63
63
  let(:frame_type) { :binary }
64
- let(:decoded_text) { "a" * 256 }
64
+ let(:decoded_text) { 'a' * 256 }
65
65
  let(:encoded_text) { "\x82\x7E\x01\x00" + decoded_text }
66
66
  let(:require_sending) { true }
67
67
 
68
68
  it_should_behave_like 'valid_outgoing_frame'
69
69
  end
70
70
 
71
- context "should properly encode 64KiB binary frame" do
71
+ context 'should properly encode 64KiB binary frame' do
72
72
  let(:frame_type) { :binary }
73
- let(:decoded_text) { "a" * 65536 }
73
+ let(:decoded_text) { 'a' * 65_536 }
74
74
  let(:encoded_text) { "\x82\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
75
75
  let(:require_sending) { true }
76
76
 
77
77
  it_should_behave_like 'valid_outgoing_frame'
78
78
  end
79
79
 
80
- context "should return error for unknown frame type" do
80
+ context 'should return error for unknown frame type' do
81
81
  let(:frame_type) { :unknown }
82
- let(:decoded_text) { "Hello" }
82
+ let(:decoded_text) { 'Hello' }
83
83
  let(:encoded_text) { nil }
84
84
  let(:error) { :unknown_frame_type }
85
85
  let(:require_sending) { false }