* run websocket-gateway in spec_helper intsead of initializer for tests VRFS-1509

This commit is contained in:
Seth Call 2014-03-21 04:44:34 +00:00
parent b058f19692
commit 4aece93b87
4 changed files with 25 additions and 6 deletions

View File

@ -64,8 +64,6 @@ module JamWebEventMachine
def self.run
Thread.new do
#ActiveRecord::Base.connection.disconnect!
ActiveRecord::Base.establish_connection
run_em
end
end

View File

@ -43,7 +43,7 @@ SampleApp::Application.configure do
# For testing omniauth
OmniAuth.config.test_mode = true
config.websocket_gateway_enable = true
config.websocket_gateway_enable = false
config.websocket_gateway_port = 6769
config.websocket_gateway_uri = "ws://localhost:#{config.websocket_gateway_port}/websocket"

View File

@ -1,5 +1,3 @@
unless $rails_rake_task
JamWebEventMachine.start
@ -15,5 +13,6 @@ unless $rails_rake_task
:rabbitmq_host => APP_CONFIG.rabbitmq_host,
:rabbitmq_port => APP_CONFIG.rabbitmq_port)
end
end
end

View File

@ -22,7 +22,7 @@ ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.ym
require 'jam_ruby'
# uncomment this to see active record logs
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
# ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
include JamRuby
# put ActionMailer into test mode
@ -32,6 +32,7 @@ RecordedTrack.observers.disable :all # only a few tests want this observer activ
# a way to kill tests if they aren't running. capybara is hanging intermittently, I think
tests_started = false
Thread.new {
sleep 30
unless tests_started
@ -40,6 +41,27 @@ Thread.new {
end
}
Thread.new do
ActiveRecord::Base.connection.disconnect!
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"])
require 'jam_websockets'
begin
JamWebsockets::Server.new.run(
:port => 6769,
:emwebsocket_debug => false,
:connect_time_stale => 2,
:connect_time_expire => 5,
:rabbitmq_host => 'localhost',
:rabbitmq_port => 5672)
rescue Exception => e
puts "websocket-gateway failed: #{e}"
end
end
ActiveRecord::Base.connection.disconnect!
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"])
#Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll