aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_helper.rb
blob: 2b1ddb237f26e9042167f13c5837895595a8545f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require "rubygems"
require "bundler"

gem 'minitest'
require "minitest/autorun"

Bundler.setup
Bundler.require :default, :test

require 'puma'

require 'action_cable'
ActiveSupport.test_order = :sorted

class ActionCableTest < ActiveSupport::TestCase
  PORT = 420420

  setup :start_puma_server
  teardown :stop_puma_server

  def start_puma_server
    events = Puma::Events.new(StringIO.new, StringIO.new)
    binder = Puma::Binder.new(events)
    binder.parse(["tcp://0.0.0.0:#{PORT}"], self)
    @server = Puma::Server.new(app, events)
    @server.binder = binder
    @server.run
  end

  def stop_puma_server
    @server.stop(true)
  end

  def websocket_url
    "ws://0.0.0.0:#{PORT}/"
  end

  def log(*args)
  end

end