lib/下代码的 rspec 测试在哪里? [英] Where do rspec tests for code under lib/ go?

查看:30
本文介绍了lib/下代码的 rspec 测试在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 lib/目录中有一些并不真正属于控件、模型或帮助程序的代码.我想为此代码编写一些 rspec 测试,但不确定它们应该放在 spec/目录下的什么位置.是否有普遍遵循的惯例?

I've got some code in the lib/ directory that don't really belong under controls, models or helpers. I'd like to write some rspec tests for this code, but am not sure where they should go under the spec/ directory. Is there a convention that's commonly followed?

推荐答案

我也会使用/spec 的子目录.但是,如果代码真的是独立的并且可以独立测试,我会考虑将代码重构为单独的插件或 gem.在这个插件中,您可以创建一个单独的规范目录.

I would use a subdirectory of /spec as well. However, I would consider refactoring the code into a separate plugin or gem if it is really separate and can be tested standalone. In this plugin, you can create a separate spec-directory.

这篇关于lib/下代码的 rspec 测试在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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