Skip to content

Commit

Permalink
way to start chat app
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Aug 9, 2017
1 parent be49916 commit 65bc121
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spec/chat_server_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
MessageBus.config[:backend] = :memory

# Run the Chat Sinatra app.
require "#{chat_example_path}/chat"
require File.join(chat_example_path, 'chat')

RSpec.configure do |config|
config.around(:all) do |example|
Thread.abort_on_exception = true
server = Thread.new { Chat.run! }

retries = 0
begin
Socket.tcp('localhost', 9292, connect_timeout: 1)
rescue Errno::ECONNREFUSED
sleep 1 && retry if (retries = retries.succ) < 10
if (retries = retries.succ) < 10
warn 'waiting for chat server to start on localhost:9292'
sleep 1
retry
end
end

example.run
Expand Down

0 comments on commit 65bc121

Please sign in to comment.