Rspec,测试宝石 [英] Rspec, test Gems
问题描述
通过添加 acts_as_gmappable
,我开发了一个在模型中使用的gem,并且可以在声明中传递选项。
现在我想用Rspec编写测试,我坚持所有与模型相关的函数:
我知道如何在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屋!