您将如何测试部分RSpec?(How would you go about testing partial, RSpec?)
让我说我有一个非常复杂的视图,具有非常复杂的测试规范。 我想为它添加另一个功能,我想用RSpec推动开发。
我想在Employee类中添加联系人。
在employee.html.erb的某处我添加了一行:
#lots of data rendered so far <%= render @employee.contacts %> #even more here
目前我还不知道
_contact.html.erb
部分需要看起来像什么。 要直接从我的员工主视图规范show.html.erb_spec.rb
测试它,我将不得不做很多设置填充或模拟不同的数据库员工是从(项目,部门等)构建的。我现在需要测试的只是部分,我不关心这个员工目前所属的部门,项目和其他事情,我不想花时间嘲笑他们。 我稍后可能会将它添加到我的主要规范中并创建测试整个视图所需的一切,但不仅仅是喷射。
您是否有任何技术或方法来创建Employee实例,向其添加一些联系人,以及仅针对部分测试视图? 无需担心Employee构建的所有其他事情。
IGEL答案的最新消息:
我同意你的意见,并且测试期望(...)。接收(:render)对于请求规范是100%的,如果我已经有了部分模板,我就不会再进一步了。 我只是想走极端,通过RSpec推动我的div和跨度。 不测试新功能的行为,但它看起来。 你认为它不值得吗?
我根本不测试视图(结构),但我看过一些像Rails Tutorial这样的文档,Michael不仅测试行为,还测试结构。 我以为我会试一试:)
Lets say I have a very complicated view with a very complicated test spec. I would like add another feature to it and I would like to drive the development with RSpec.
I would like to add contacts to Employee class.
Somewhere in the employee.html.erb I add the line:
#lots of data rendered so far <%= render @employee.contacts %> #even more here
At the moment I don't really know what
_contact.html.erb
partial needs to look like. To test it directly from my main view spec for employees,show.html.erb_spec.rb
, I would have to do a lot of set up populating or mocking different database employee is build from(projects, departments etc.).All I need to test for now is that partial, I don't care about departments, projects and other things this employee currently belongs to and I don't want to spend my time on mocking them all up. I will probably add it to my main spec later on and create everything needed to test the entire view but not just jet.
Do you have any technique or way for creating an instance of Employee, adding a few Contacts to it, and testing the view for just the partial? Without worrying about all the other things the Employee is built from.
UPDATE FOR IGEL ANSWER:
I agree with you, and testing for expect(...).to receive(:render) is 100% enough for request spec and I would go no further if I already had a partial template. I just wanted to go extreme and drive my div's and span's through RSpec. Not testing for behaviour of new feature but it look. Do you suggest its not worth it?
I don't test views(structure) at all but I have seen a few documents like Rails Tutorial where Michael is not only testing behaviour but as well structure. I thought I'll give it a go:)
原文:
最满意答案
尝试改变Android工作室的主题,你可以这样做
File->Settings->Editor->Colors & Fonts->
在方案名称中选择Darcula并申请查看一个很棒的黑暗背景主题编辑器在MacAndroid Studio -> Preferences ->
您可以从http://ideacolorthemes.org/下载新主题
下载.jar文件后,转到文件 - >导入设置...并选择下载的文件。
Try to change the theme of Android studio, you can do so by
File->Settings->Editor->Colors & Fonts->
In scheme name select Darcula and apply to see a awesome dark background theme editor On macAndroid Studio -> Preferences ->
You can download new themes from http://ideacolorthemes.org/
Once you have downloaded the .jar file, go to File -> Import Settings... and choose the file downloaded.
相关问答
更多-
请问为什么现在从官网下载的android studio ide不附带sdk了?[2023-08-27]
我也下不到,可是我先装android studio,之后发现里面sdk 可以和eclipse共用 -
打破所有例外,被抓住或未被捕获: 通过运行 - >查看断点打开断点窗口。 出现“断点”对话框。 在左窗格中,滚动到底部。 在Java异常断点下选择任何异常 选择任何异常后 ,在右窗格中配置如下: 暂停:已检查 全部:已选择 条件: !(this instanceof java.lang.ClassNotFoundException) 通知: 被捕获的异常和未捕获的异常被选中 检查类别过滤器复选框以启用类过滤( 如@Scott Barta所述 )。 然后单击... (elipsis)按钮打开“类别过滤器”对话 ...
-
绝对可能,因为Android Studio实际上使用相同的Gradle命令来构建APK。 假设您已经设置了签名配置,您可以使用: ./gradlew :app:assembleRelease 或者如果你在Windows上: gradlew.bat :app:assembleRelease 一般情况下你可以使用 ./gradlew tasks 为了探索可以从命令行运行的所有任务。 Is absolutely possible because Android Studio actually uses th ...
-
图1的标题位于http://developer.android.com/training/basics/firstapp/creating-project.html,上面写着“Eclipse中的新活动向导”。 这是ADT。 Eclipse 3.6.2此时已有很多年了。 目前的版本是4.4.1。 The caption for Figure 1 at http://developer.android.com/training/basics/firstapp/creating-project.html read ...
-
适用于Android的IDE(IDE for Android)[2023-05-02]
直接在android? 不,我不这么认为。 但是可以在平板电脑上安装ubuntu。 然后你可以使用eclipse或任何其他Linux IDE。 下面是一段视频,向您展示如何在平板电脑上安装ubuntu。 http://www.youtube.com/watch?v=agYEOefFfto UPDATE 终端IDE允许在您的Android设备上进行完整的java / android开发(无需root)。 我相信C和C ++支持也在进行中。 Project是开源的,包括以下可执行文件: javac,java,d ... -
更改Android Studio中使用的字体(IDE,而不是应用程序)(Change font used in Android Studio (the IDE, not in apps))[2022-08-14]
您可以导航到文件>设置>外观,然后选中复选框Override default font by图像中的Override default font by并更改默认值。 You can navigate to File>Settings>Appearance and then check the checkbox Override default font by in image and change the defaults. -
Android Studio 1.1.0 IDE显示错误错误(红色)(Android Studio 1.1.0 IDE showing false errors (in red))[2022-10-11]
另一个安装后问题得到解决。 可能与安装选项有关。 The problem resolved after another install. Probably something to do with installation options. -
Android Studio IDE更新(Android Studio IDE Update)[2022-04-21]
这是因为Android Studio可以在磁盘中保存多个副本。 这就是说你现在有两个android-studio文件夹,代表version 1.5.1和version 2.1.2 。 您只需删除代表version 1.5.1文件夹并在version 2.1.2文件夹中找到studio64.exe ,然后右键单击该文件,然后选择将其发送到开始菜单。 顺便说一句,SDK也可以保存多个副本。 您可以在Android Studio的设置中选择要使用的sdk。 如果你在Windows平台上使用AS,你可以选择三种包。 ... -
多年来,谷歌员工和胆大妄为的程序员都在使用Android Studio的“非官方”测试版本,该版本被视为尚未准备好向公众开放。 2014年11月,谷歌在Nexus 6上推出了Lollipop 5.0,并且还推出了Android Studio的一个版本,该版本对于普通开发者来说足够稳定,他们称之为“官方”。 虽然Eclipse SDK管理器继续提供最新的API平台包,但Eclipse的ADT工具集不再被维护。 我相信上一次稳定版本是在2014年7月。只有Android Studio才会收到ADT工具更新。 这 ...
-
如何向Android IDE Studio添加更多标识符颜色 - Android(How to add more identifier colors to Android IDE Studio - Android)[2023-11-08]
尝试改变Android工作室的主题,你可以这样做 File->Settings->Editor->Colors & Fonts->在方案名称中选择Darcula并申请查看一个很棒的黑暗背景主题编辑器在Mac Android Studio -> Preferences -> 您可以从http://ideacolorthemes.org/下载新主题 下载.jar文件后,转到文件 - >导入设置...并选择下载的文件。 Try to change the theme of Android studio, you ...