Ruby on rails 测试Faye从Rails应用程序到Faye服务器的消息成功

Ruby on rails 测试Faye从Rails应用程序到Faye服务器的消息成功,ruby-on-rails,eventmachine,faye,Ruby On Rails,Eventmachine,Faye,我有我的主Rails服务器和一个单独的Faye服务器(localhost:9292),可以正确地处理消息传递。一切正常,但我在尝试测试时遇到了问题 我正在尝试将我的测试设置为每天运行一次的worker,如果没有收到消息,我希望应用程序向我发送电子邮件。以下是我根据中的信息得到的信息 需要“eventmachine” 需要“faye/websocket” 类PingFayeServerWorker

我有我的主Rails服务器和一个单独的Faye服务器(localhost:9292),可以正确地处理消息传递。一切正常,但我在尝试测试时遇到了问题

我正在尝试将我的测试设置为每天运行一次的worker,如果没有收到消息,我希望应用程序向我发送电子邮件。以下是我根据中的信息得到的信息

需要“eventmachine”
需要“faye/websocket”
类PingFayeServerWorkerHello world')
publication.do
放置“服务器收到的消息!”
结束
publication.errback do |错误|
放置“出现问题:”+错误消息
结束
}
结束
结束
require 'eventmachine'
require 'faye/websocket'

class PingFayeServerWorker < BaseWorker

  def initialize

  end

  def process
    EventMachine.run {
      client = Faye::Client.new('http://localhost:9292/faye')
      client.set_header('Authorization', 'OAuth abcd-1234')

      client.subscribe('/foo') do |message|
        puts message.inspect
      end

      publication = client.publish('/foo', 'text' => 'Hello world')

      publication.callback do
        puts 'Message received by server!'
      end

      publication.errback do |error|
        puts 'There was a problem: ' + error.message
      end
    }
  end
end