A gem that allows controller specs to generate markup which can be used as HTML fixtures within javascript tests written using Jasmine and JSTestDriver.
To use this follow these steps:
-
Add the dependency for your gem in Gemfile:
gem ‘js_fixtures’
-
Within the controller specs, call the method to create fixtures as follows:
save_fixture(html_for(‘body’),‘Signup’)
The above will save the content of the body in file Signup.js in the path ‘spec/javascripts/helpers/’. The file will have a method loadSignupFixture which contains the HTML fixture.
-
Call the same in the JS tests in beforeEach section:
beforeEach(function () {
$(this).ready(function () {
loadSignupFixture()
});
});