Skip to content

Commit 0ca75c5

Browse files
committed
SpectrumChecks: Initialize code base
Signed-off-by: duangsuse <fedora-opensuse@outlook.com>
1 parent 1ba30d5 commit 0ca75c5

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.idea/dictionaries/DuangSUSE.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spectrum_checks.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require './spectrum'
22
require 'rspec'
33

4+
require 'socket'
5+
include Socket::Constants
6+
47
RSpec.configure do |config|
58
config.disable_monkey_patching!
69

@@ -9,7 +12,49 @@
912
end
1013
end
1114

15+
SERVER_PORT = 8080
16+
17+
18+
#sock_addr = Socket.pack_sockaddr_in(SERVER_PORT, 'localhost')
19+
20+
begin
21+
socket = TCPSocket.new('localhost', SERVER_PORT)
22+
#socket.bind
23+
rescue Errno::EADDRINUSE
24+
puts "Server already started at port #{SERVER_PORT}"
25+
rescue
26+
puts "Starting test server"
27+
#$server = open('./gradlew bootRun')
28+
out, write = IO.pipe
29+
$server = Process.spawn('./gradlew bootRun', :out => write)
30+
puts "Created sub-process #{$server}"
31+
32+
# Wait until server is running
33+
while (line = out.gets)
34+
puts line
35+
if line.start_with?('GeekApk Server is now running')
36+
break
37+
end
38+
end
39+
end
40+
41+
at_exit do
42+
puts "Terminating sub-process #{$server}"
43+
44+
Process.kill(:TERM, $server) rescue puts "Failed to kill process"
45+
end
46+
1247
RSpec.describe 'Hello' do
1348
it 'run this test' do
1449
end
1550
end
51+
52+
RSpec.describe 'GeekApk' do
53+
ga = Spectrum::ClientShowcase.from_file('spectrum_geekapk_v1b_api.json')
54+
ga.instance_api_methods
55+
56+
it 'accepting requests' do
57+
puts (v = ga.serverVersion)
58+
expect(v).to eq('0.1.0')
59+
end
60+
end

0 commit comments

Comments
 (0)