带有测试单元和活动记录的文章/示例
我希望编写一些单元测试,让我像在 Rails 中一样构建/测试非存根 CRUD 函数,但我想使用最少数量的 gem(测试单元和活动记录)。
有人知道任何可能有帮助的资源吗?
谢谢
I'm looking to write some unit tests that will let me build/test non-stubbed CRUD functions like I can in Rails but I want to use a minimal number of gems (test unit&active record).
Anyone know of any resources that might help?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道有任何专门与此相关的资源。要让活动记录在简单的测试中工作,您只需要设置连接详细信息和模型类,假设您有一个与活动记录约定匹配的现有数据库可供使用。不知道你处于哪个阶段,但如果你只需要一个简单的例子:
除了活动记录本身所依赖的那些之外,这里没有涉及其他宝石。
您必须根据您使用的数据库适配器的类型确定所需的配置设置。如果您的数据库模式不符合活动记录约定,那么您还必须在模型类中指定一些映射。
Don't know of any resources specifically about this. To get active record working in a simple test you would just need to set up the connection details and your model classes assuming you have an existing database to work with that matches the active record conventions. Don't know what stage you are at but if you just need a simple example:
There are no other gems involved here other than those that active record itself depends on.
You'll have to work out what configuration settings you need depending on the type of database adapter you are using. If your database schema doesn't conform to the active record conventions then you will also have to specify some mappings in your model classes.