File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 11require './spectrum'
22require 'rspec'
33
4+ require 'socket'
5+ include Socket ::Constants
6+
47RSpec . configure do |config |
58 config . disable_monkey_patching!
69
912 end
1013end
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+
1247RSpec . describe 'Hello' do
1348 it 'run this test' do
1449 end
1550end
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
You can’t perform that action at this time.
0 commit comments