我一直在使用Rails 3.2中的RAPNS(3.4.1)在“生产”环境中向Apple和Google消息服务器发送通知而没有任何问题。
我现在正在尝试编写单元测试和集成测试。 该文档指出Rapns.push将一直运行,直到所有通知都已发送。 这种情况不适合我。 等待函数永远不会返回,因为“batch.complete”似乎没有返回true。
test :: unit中的步骤
添加APS证书 添加有效的设备令牌 添加Rapns :: Aps :: Notification 使用Rapns :: push() 它被发送到APS服务器但是Push没有完成并返回到test :: unit我已经使用推送参数的版本组合而没有成功。 我确实尝试过使用Rapns.embed; 它确实返回但是通知没有使用deliver_at日期设置更新
我知道有一个更新的版本,但此时不想升级到它。
有没有人在Rails中使用Rapns进行单元测试? 如果有的话,有什么诀窍吗?
在看了这个之后,代码在针对Rapns的active_record.rb中被阻塞了
notification.save!(:validate => false)Rapns正在使用一个事务,所以我认为它是阻塞的,直到测试单元发布? 听起来不太对劲
I have been using the RAPNS (3.4.1) in Rails 3.2 to send notifications to both Apple and Google messaging servers in the 'production' environment without problems.
I am now trying to write both unit and integration tests. The documentation states that Rapns.push will run until all notifications have been sent. This is not happening for me. The wait function never returns as the "batch.complete" does not appear to return true.
Steps in test::unit
Add a APS cert Add a valid device token Add a Rapns::Aps::Notification Use Rapns::push() it is sent to the APS server but Push does not complete and return to test::unitI have used versions combinations of the push parameters without success. I did try to use Rapns.embed ; it did return but the notification did not update with delivered_at date set
I know there is a newer version, but do not want to upgrade to it at this point.
Has anyone used Rapns in unit testing in Rails? And if so was there any trick to it?
After looking at this some more , the code is blocking in the active_record.rb for Rapns
notification.save!(:validate => false)Rapns is using a transaction so I assume that it is blocking until the test unit ones releases? Does not sound quite right
最满意答案
在这个问题上花了几个小时后,我决定创建非'testcase'代码。 我创建了简单的ruby类函数来运行测试,而没有子类化ActionView :: TestCase
然后Rapns :: Push按照记录的方式工作。
After spending a few more hours on the issue I decided to create non 'testcase' code. I created simple ruby class functions to run the tests without the subclassing ActionView::TestCase
Then the Rapns::Push worked as documented.
更多推荐
发布评论