如何为现有控制器生成规范? [英] How do I generate specs for existing controllers?

查看:47
本文介绍了如何为现有控制器生成规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了几个控制器.现在我想开始为他们编写规范测试.是否有自动生成规范文件的命令?我知道 rails 为新资源执行此操作,但我不知道它是否也为现有控制器/模型执行此操作.

I have several controllers already set up. Now I want to start writing spec tests for them. Is there a command that generates the spec files automatically? I know rails does this for new resources, but I don't know if it does it for existing controllers/models too.

推荐答案

rails g rspec:controller ControllerName

当它要求你覆盖现有的控制器时,输入 n.

When it asks you to override the existing controller, type n.

这篇关于如何为现有控制器生成规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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