Skip to content

Commit 6c06685

Browse files
committed
Move test fixtures into proper namespace.
1 parent ee0a558 commit 6c06685

20 files changed

+87
-84
lines changed

fixtures/connection_context.rb

-17
This file was deleted.

fixtures/frame_examples.rb

-30
This file was deleted.

fixtures/protocol/http2/a_frame.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2019-2023, by Samuel Williams.
5+
6+
require 'protocol/http2/framer'
7+
8+
module Protocol
9+
module HTTP2
10+
AFrame = Sus::Shared("a frame") do
11+
let(:pipe) {Socket.pair(:UNIX, :STREAM)}
12+
let(:remote) {pipe[0]}
13+
let(:stream) {pipe[1]}
14+
15+
let(:framer) {Protocol::HTTP2::Framer.new(stream, {subject::TYPE => subject})}
16+
17+
let(:frame) {subject.new}
18+
19+
it "is a valid frame type" do
20+
expect(frame).to be(:valid_type?)
21+
end
22+
23+
it "can write the frame" do
24+
frame.write(remote)
25+
expect(framer.read_frame).to be == frame
26+
end
27+
end
28+
end
29+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2019-2023, by Samuel Williams.
5+
6+
require 'protocol/http2/client'
7+
require 'protocol/http2/server'
8+
require 'protocol/http2/stream'
9+
10+
require 'socket'
11+
12+
module Protocol
13+
module HTTP2
14+
ConnectionContext = Sus::Shared("a connection") do
15+
let(:sockets) {Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)}
16+
17+
let(:client) {Protocol::HTTP2::Client.new(Protocol::HTTP2::Framer.new(sockets.first))}
18+
let(:server) {Protocol::HTTP2::Server.new(Protocol::HTTP2::Framer.new(sockets.last))}
19+
end
20+
end
21+
end

test/protocol/http2/client.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Released under the MIT License.
44
# Copyright, 2019-2023, by Samuel Williams.
55

6-
require 'connection_context'
6+
require 'protocol/http2/connection_context'
77

88
describe Protocol::HTTP2::Client do
9-
include_context ConnectionContext
9+
include_context Protocol::HTTP2::ConnectionContext
1010

1111
let(:framer) {server.framer}
1212

test/protocol/http2/connection.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright, 2019-2024, by Samuel Williams.
55
# Copyright, 2023, by Marco Concetto Rudilosso.
66

7-
require 'connection_context'
7+
require 'protocol/http2/connection_context'
88

99
describe Protocol::HTTP2::Connection do
1010
let(:stream) {StringIO.new}
@@ -100,7 +100,7 @@
100100
end
101101

102102
with 'client and server' do
103-
include_context ConnectionContext
103+
include_context Protocol::HTTP2::ConnectionContext
104104

105105
it "can negotiate connection" do
106106
first_server_frame = nil

test/protocol/http2/continuation_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/continuation_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::ContinuationFrame do
1010
let(:data) {"Hello World!"}
1111
let(:frame) {subject.new}
1212

13-
it_behaves_like FrameExamples do
13+
it_behaves_like Protocol::HTTP2::AFrame do
1414
def before
1515
frame.pack data
1616

test/protocol/http2/data_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/data_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::DataFrame do
1010
let(:frame) {subject.new}
1111

12-
it_behaves_like FrameExamples do
12+
it_behaves_like Protocol::HTTP2::AFrame do
1313
def before
1414
frame.pack "Hello World!"
1515

test/protocol/http2/dependency.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Released under the MIT License.
44
# Copyright, 2020-2023, by Samuel Williams.
55

6-
require 'connection_context'
6+
require 'protocol/http2/connection_context'
77

88
describe Protocol::HTTP2::Stream do
9-
include_context ConnectionContext
9+
include_context Protocol::HTTP2::ConnectionContext
1010

1111
def before
1212
client.open!

test/protocol/http2/goaway_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Copyright, 2019-2024, by Samuel Williams.
55

66
require 'protocol/http2/goaway_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::GoawayFrame do
1010
let(:data) {"Hikikomori desu!"}
1111
let(:frame) {subject.new}
1212

13-
it_behaves_like FrameExamples do
13+
it_behaves_like Protocol::HTTP2::AFrame do
1414
def before
1515
frame.pack 1, 2, data
1616

test/protocol/http2/headers_frame.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
require 'protocol/http2/headers_frame'
77

8-
require 'connection_context'
9-
require 'frame_examples'
8+
require 'protocol/http2/connection_context'
9+
require 'protocol/http2/a_frame'
1010

1111
describe Protocol::HTTP2::HeadersFrame do
1212
let(:priority) {Protocol::HTTP2::Priority.new(true, 42, 7)}
1313
let(:data) {"Hello World!"}
1414
let(:frame) {subject.new}
1515

16-
it_behaves_like FrameExamples do
16+
it_behaves_like Protocol::HTTP2::AFrame do
1717
def before
1818
frame.set_flags(Protocol::HTTP2::END_HEADERS)
1919
frame.pack priority, data
@@ -103,7 +103,7 @@ def before
103103
end
104104

105105
with "client/server connection" do
106-
include_context ConnectionContext
106+
include_context Protocol::HTTP2::ConnectionContext
107107

108108
def before
109109
client.open!

test/protocol/http2/ping_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/ping_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::PingFrame do
1010
let(:data) {"PingPong"}
1111
let(:frame) {subject.new}
1212

13-
it_behaves_like FrameExamples do
13+
it_behaves_like Protocol::HTTP2::AFrame do
1414
def before
1515
frame.pack data
1616

test/protocol/http2/priority_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/priority_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::Priority do
1010
let(:priority) {subject.new}
@@ -45,7 +45,7 @@
4545
let(:priority) {Protocol::HTTP2::Priority.new(true, 42, 7)}
4646
let(:frame) {subject.new}
4747

48-
it_behaves_like FrameExamples do
48+
it_behaves_like Protocol::HTTP2::AFrame do
4949
def before
5050
frame.pack priority
5151

test/protocol/http2/push_promise_frame.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/push_promise_frame'
7-
require 'connection_context'
8-
require 'frame_examples'
7+
require 'protocol/http2/connection_context'
8+
require 'protocol/http2/a_frame'
99

1010
describe Protocol::HTTP2::PushPromiseFrame do
1111
let(:stream_id) {5}
1212
let(:data) {"Hello World!"}
1313
let(:frame) {subject.new}
1414

15-
it_behaves_like FrameExamples do
15+
it_behaves_like Protocol::HTTP2::AFrame do
1616
def before
1717
frame.set_flags(Protocol::HTTP2::END_HEADERS)
1818
frame.pack stream_id, data
@@ -39,7 +39,7 @@ def before
3939
end
4040

4141
with "client/server connection" do
42-
include_context ConnectionContext
42+
include_context Protocol::HTTP2::ConnectionContext
4343

4444
def before
4545
client.open!

test/protocol/http2/reset_stream_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/reset_stream_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::ResetStreamFrame do
1010
let(:error) {Protocol::HTTP2::INTERNAL_ERROR}
1111
let(:frame) {subject.new}
1212

13-
it_behaves_like FrameExamples do
13+
it_behaves_like Protocol::HTTP2::AFrame do
1414
def before
1515
frame.pack error
1616

test/protocol/http2/server.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Released under the MIT License.
44
# Copyright, 2019-2024, by Samuel Williams.
55

6-
require 'connection_context'
6+
require 'protocol/http2/connection_context'
77

88
describe Protocol::HTTP2::Client do
9-
include_context ConnectionContext
9+
include_context Protocol::HTTP2::ConnectionContext
1010

1111
let(:framer) {client.framer}
1212

test/protocol/http2/settings_frame.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/settings_frame'
7-
require 'frame_examples'
7+
require 'protocol/http2/a_frame'
88

99
describe Protocol::HTTP2::SettingsFrame do
1010
let(:settings) {[
1111
[3, 10], [5, 1048576], [4, 2147483647], [8, 1]
1212
]}
1313
let(:frame) {subject.new}
1414

15-
it_behaves_like FrameExamples do
15+
it_behaves_like Protocol::HTTP2::AFrame do
1616
def before
1717
frame.pack settings
1818

test/protocol/http2/stream.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Released under the MIT License.
44
# Copyright, 2019-2023, by Samuel Williams.
55

6-
require 'connection_context'
6+
require 'protocol/http2/connection_context'
77

88
describe Protocol::HTTP2::Stream do
9-
include_context ConnectionContext
9+
include_context Protocol::HTTP2::ConnectionContext
1010

1111
def before
1212
client.open!

test/protocol/http2/window.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the MIT License.
44
# Copyright, 2019-2023, by Samuel Williams.
55

6-
require 'connection_context'
6+
require 'protocol/http2/connection_context'
77

88
describe Protocol::HTTP2::Window do
99
let(:window) {subject.new}

test/protocol/http2/window_update_frame.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
# Copyright, 2019-2023, by Samuel Williams.
55

66
require 'protocol/http2/window_update_frame'
7-
require 'connection_context'
8-
require 'frame_examples'
7+
require 'protocol/http2/connection_context'
8+
require 'protocol/http2/a_frame'
99

1010
describe Protocol::HTTP2::WindowUpdateFrame do
1111
let(:window_size_increment) {1024}
1212
let(:frame) {subject.new}
1313

14-
it_behaves_like FrameExamples do
14+
it_behaves_like Protocol::HTTP2::AFrame do
1515
def before
1616
frame.pack window_size_increment
1717

@@ -52,7 +52,7 @@ def before
5252
end
5353

5454
with 'a connection' do
55-
include_context ConnectionContext
55+
include_context Protocol::HTTP2::ConnectionContext
5656

5757
let(:framer) {client.framer}
5858

0 commit comments

Comments
 (0)