Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions for CI #162

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:
branches:
- master

pull_request:

jobs:
test:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby: ['3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4']

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run RSpec tests
run: bundle exec rake
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gemspec
gem "em-websocket-client", git: "[email protected]:movitto/em-websocket-client.git", branch: "expose-websocket-api"
gem "em-spec", "~> 0.2.6"
gem "em-http-request", "~> 1.1.1"
gem "rspec", "~> 3.5.0"
gem "rspec"
gem "rake"
38 changes: 19 additions & 19 deletions spec/integration/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
start_server do |ws|
ws.onopen { |handshake|
headers = handshake.headers
headers["Connection"].should == "Upgrade"
headers["Upgrade"].should == "websocket"
headers["Host"].to_s.should == "127.0.0.1:12345"
handshake.path.should == "/"
handshake.query.should == {}
handshake.origin.should == 'http://example.com'
expect(headers["Connection"]).to eq "Upgrade"
expect(headers["Upgrade"]).to eq "websocket"
expect(headers["Host"].to_s).to eq "127.0.0.1:12345"
expect(handshake.path).to eq "/"
expect(handshake.query).to eq({})
expect(handshake.origin).to eq 'http://example.com'
}
ws.onclose {
ws.state.should == :closed
expect(ws.state).to eq :closed
done
}
end
Expand All @@ -59,13 +59,13 @@

start_server do |ws|
ws.onopen { |handshake|
handshake.path.should == '/hello'
handshake.query_string.split('&').sort.
should == ["baz=qux", "foo=bar"]
handshake.query.should == {"foo"=>"bar", "baz"=>"qux"}
expect(handshake.path).to eq '/hello'
expect(handshake.query_string.split('&').sort)
.to eq ["baz=qux", "foo=bar"]
expect(handshake.query).to eq({"foo"=>"bar", "baz"=>"qux"})
}
ws.onclose {
ws.state.should == :closed
expect(ws.state).to eq :closed
done
}
end
Expand All @@ -77,9 +77,9 @@
# 1. Start WebSocket server
start_server { |ws|
# 3. Try to send a message to the socket
lambda {
expect {
ws.send('early message')
}.should raise_error('Cannot send data before onopen callback')
}.to raise_error('Cannot send data before onopen callback')
done
}

Expand All @@ -99,10 +99,10 @@
start_server do |ws|
ws.onopen { |handshake|
headers = handshake.headers
headers["Host"].to_s.should == "127.0.0.1:12345"
expect(headers["Host"].to_s).to eq "127.0.0.1:12345"
}
ws.onclose {
ws.state.should == :closed
expect(ws.state).to eq :closed
done
}
end
Expand All @@ -116,8 +116,8 @@
# Increase the message size by one on each loop
ws.onmessage{|msg| ws.send(msg + "x") }
ws.onclose{|status|
status[:code].should == 1006 # Unclean
status[:was_clean].should be false
expect(status[:code]).to eq 1006 # Unclean
expect(status[:was_clean]).to be false
}
end

Expand All @@ -127,7 +127,7 @@
ws.disconnect { done } # Server closed the connection
ws.stream { |msg|
# minus frame size ? (getting 146 max here)
msg.data.size.should <= 150
expect(msg.data.size).to be <= 150
# Return back the message
ws.send_msg(msg.data)
}
Expand Down
36 changes: 18 additions & 18 deletions spec/integration/draft03_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def start_client
em {
start_server { |ws|
ws.onmessage { |msg|
msg.should == 'Hello'
expect(msg).to eq 'Hello'
done
}
}
Expand All @@ -72,7 +72,7 @@ def start_client
em {
start_server { |ws|
ws.onmessage { |msg|
msg.should == 'Hello'
expect(msg).to eq 'Hello'
done
}
}
Expand Down Expand Up @@ -100,7 +100,7 @@ def start_client

connection.onmessage { |frame|
next if frame.nil?
frame.should == "\x03\x05Hello"
expect(frame).to eq "\x03\x05Hello"
done
}
}
Expand All @@ -112,8 +112,8 @@ def start_client

start_server { |ws|
ws.onbinary { |msg|
msg.encoding.should == Encoding.find("BINARY") if defined?(Encoding)
msg.should == data
expect(msg.encoding).to eq Encoding.find("BINARY") if defined?(Encoding)
expect(msg).to eq data
done
}
}
Expand All @@ -133,8 +133,8 @@ def start_client

start_server { |ws|
ws.onbinary { |msg|
msg.encoding.should == Encoding.find("BINARY") if defined?(Encoding)
msg.should == data
expect(msg.encoding).to eq Encoding.find("BINARY") if defined?(Encoding)
expect(msg).to eq data
done
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ def start_client

# Check that close ack received
connection.onmessage { |frame|
frame.should == "\x01\x00"
expect(frame).to eq "\x01\x00"
done
}
}
Expand All @@ -183,11 +183,11 @@ def start_client

# 5. Onclose event on server
ws.onclose { |event|
event.should == {
expect(event).to eq({
:code => 1005,
:reason => "",
:was_clean => true,
}
})
done
}
}
Expand All @@ -197,14 +197,14 @@ def start_client

# 3. Check that close frame recieved and acknowlege it
connection.onmessage { |frame|
frame.should == "\x01\x00"
expect(frame).to eq "\x01\x00"
ack_received = true
connection.send_data("\x01\x00")
}

# 4. Check that connection is closed _after_ the ack
connection.onclose {
ack_received.should == true
expect(ack_received).to eq true
}
}
end
Expand All @@ -215,11 +215,11 @@ def start_client
em {
start_server { |ws|
ws.onclose { |event|
event.should == {
expect(event).to eq ({
:code => 1005,
:reason => "",
:was_clean => true,
}
})
done
}
}
Expand All @@ -242,9 +242,9 @@ def start_client

# 3. Check that exception raised if I attempt to send more data
EM.add_timer(0.1) {
lambda {
expect {
ws.send('hello world')
}.should raise_error(EM::WebSocket::WebSocketError, 'Cannot send data frame since connection is closing')
}.to raise_error(EM::WebSocket::WebSocketError, 'Cannot send data frame since connection is closing')
done
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ def start_client
connection.send_data("\x02\x05Hello")
else
# 4. Check that the pong is received
frame.should == "\x03\x05Hello"
expect(frame).to eq "\x03\x05Hello"
done
end
}
Expand All @@ -287,7 +287,7 @@ def start_client
em {
start_server { |ws|
ws.onopen {
ws.supports_close_codes?.should == false
expect(ws.supports_close_codes?).to eq false
done
}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/draft05_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def start_client
em {
start_server { |ws|
ws.onopen {
ws.supports_close_codes?.should == false
expect(ws.supports_close_codes?).to eq false
done
}
}
Expand Down
20 changes: 10 additions & 10 deletions spec/integration/draft06_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def start_client
em {
start_server { |server|
server.onopen {
server.instance_variable_get(:@handler).class.should == EventMachine::WebSocket::Handler06
expect(server.instance_variable_get(:@handler).class).to eq EventMachine::WebSocket::Handler06
}
}

start_client { |client|
client.onopen {
client.handshake_response.lines.sort.
should == format_response(@response).lines.sort
expect(client.handshake_response.lines.sort)
.to eq format_response(@response).lines.sort
done
}
}
Expand All @@ -68,9 +68,9 @@ def start_client
em {
start_server { |server|
server.onmessage { |msg|
msg.should == 'Hello'
expect(msg).to eq 'Hello'
if msg.respond_to?(:encoding)
msg.encoding.should == Encoding.find("UTF-8")
expect(msg.encoding).to eq Encoding.find("UTF-8")
end
done
}
Expand All @@ -92,11 +92,11 @@ def start_client
start_server { |ws|
ws.onclose { |event|
# 2. Receive close event in server
event.should == {
expect(event).to eq({
:code => 4004,
:reason => "close reason",
:was_clean => true,
}
})
done
}
}
Expand All @@ -115,11 +115,11 @@ def start_client
em {
start_server { |ws|
ws.onclose { |event|
event.should == {
expect(event).to eq({
:code => 1005,
:reason => "",
:was_clean => true,
}
})
done
}
}
Expand All @@ -135,7 +135,7 @@ def start_client
em {
start_server { |ws|
ws.onopen {
ws.supports_close_codes?.should == true
expect(ws.supports_close_codes?).to eq true
done
}
}
Expand Down
14 changes: 7 additions & 7 deletions spec/integration/draft13_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def start_client
connection = start_client

connection.onopen {
connection.handshake_response.lines.sort.
should == format_response(@response).lines.sort
expect(connection.handshake_response.lines.sort)
.to eq format_response(@response).lines.sort
done
}
}
Expand All @@ -67,14 +67,14 @@ def start_client
em {
start_server { |ws|
ws.onopen {
ws.should be_pingable
expect(ws).to be_pingable
EM.next_tick {
ws.ping('hello').should == true
expect(ws.ping('hello')).to eq true
}

}
ws.onpong { |data|
data.should == 'hello'
expect(data).to eq 'hello'
done
}
}
Expand All @@ -84,7 +84,7 @@ def start_client
# Confusing, fake onmessage means any data after the handshake
connection.onmessage { |data|
# This is what a ping looks like
data.should == "\x89\x05hello"
expect(data).to eq "\x89\x05hello"
# This is what a pong looks like
connection.send_data("\x8a\x05hello")
}
Expand All @@ -95,7 +95,7 @@ def start_client
em {
start_server { |ws|
ws.onopen {
ws.supports_close_codes?.should == true
expect(ws.supports_close_codes?).to eq true
done
}
}
Expand Down
Loading