Rspec,测试宝石 [英] Rspec, test Gems

查看:147
本文介绍了Rspec,测试宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过添加 acts_as_gmappable ,我开发了一个在模型中使用的gem,并且可以在声明中传递选项。



现在我想用Rspec编写测试,我坚持所有与模型相关的函数:


  • 检查如果地理编码正确完成

  • 选中我从所有数据库条目创建正确的json

  • etc ...



我知道如何在Rails应用程序中执行这些操作,但最好不要用于创建宝石。任何追踪?

解决方案

我设法通过阅读Jose Valim的优秀书:



http://plataformatec.com.br/crafting-rails-applications /



他描述了他如何使用他的引擎构建器测试他的创业宝:

https://github.com/josevalim/enginex


I've developed a gem which is to use inside a model by adding acts_as_gmappable and it's possible to pass options in the declaration.

Now that I want to write tests with Rspec, I'm stuck for all model related functions:

  • check if geocoding was properly done
  • check I create a proper json from all database entries
  • etc ...

I know how to do these inside a Rails app but definitly not for a gem. Any track?

解决方案

I managed to do this by reading the excellent book of Jose Valim:

http://plataformatec.com.br/crafting-rails-applications/

He describes how he tests his gem using his engine builder:

https://github.com/josevalim/enginex

这篇关于Rspec,测试宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆