Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. But i was wondering if anyone knew how to test the javascript view files in rails?

The Blue Ridge framework(as far as i could understand) lets you test only the javascript files. But I wanted to test my "js.erb" files which also manipulate the DOM.

Anyone has any insights?

like image 854
Punit Rathore Avatar asked Feb 20 '26 05:02

Punit Rathore


1 Answers

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. To test ajax responses, you can save a response fixture and then load both the view and response fixtures into your test.

I don't use Blue Ridge, I use 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.

like image 139
José Fernandes Avatar answered Feb 22 '26 17:02

José Fernandes