[英]Testing js.erb files in rails
I recently had a look at the awesome Blue Ridge Javascript testing framework to test javascript on my rails app. 我最近看了一下很棒的Blue Ridge Javascript测试框架来测试我的rails应用程序上的javascript。 But i was wondering if anyone knew how to test the javascript view files in rails?
但我想知道是否有人知道如何在rails中测试javascript视图文件?
The Blue Ridge framework(as far as i could understand) lets you test only the javascript files. Blue Ridge框架(据我所知)可以让你只测试javascript文件。 But I wanted to test my "js.erb" files which also manipulate the DOM.
但我想测试我的“js.erb”文件,它们也操纵DOM。
Anyone has any insights? 任何人都有任何见解?
What I do is to use a slightly modified version of these two functions I googled, save_fixture and html_for, to save view fixtures, which I load into the tests. 我所做的是使用我用googled 这两个函数稍微修改过的版本save_fixture和html_for来保存视图夹具,我将其加载到测试中。 To test ajax responses, you can save a response fixture and then load both the view and response fixtures into your test.
要测试ajax响应,可以保存响应夹具,然后将视图和响应夹具加载到测试中。
I don't use Blue Ridge, I use jasmine/jasmine-jquery. 我不使用Blue Ridge,我使用jasmine / jasmine-jquery。 So I don't know if it has a loadFixtures() feature, which loads a file for test, but that's the pattern.
所以我不知道它是否有一个loadFixtures()函数,它加载一个文件进行测试,但这就是模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.