在Rails单元测试环境中使用RAPNS(Using RAPNS in the Rails Unit Test environment)

编程入门 行业动态 更新时间:2024-10-27 17:19:13
在Rails单元测试环境中使用RAPNS(Using RAPNS in the Rails Unit Test environment)

我一直在使用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::unit

I 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.

更多推荐

本文发布于:2023-07-26 10:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1274334.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   环境   Rails   RAPNS   environment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!