Starting spec for rails.js

This commit is contained in:
Thomas R. Koll 2010-12-29 17:43:50 +01:00
parent 06d80d0e57
commit 5e1f5ff5b1
3 changed files with 26 additions and 2 deletions

View file

@ -11,12 +11,13 @@
beforeEach(function() {
$('#jasmine_content').empty();
spec.clearLiveEventBindings();
// NOTE Commented (as well as in afterEach) to keep the listeners from rails.js alive.
//spec.clearLiveEventBindings();
jasmine.Clock.useMock();
});
afterEach(function() {
spec.clearLiveEventBindings();
//spec.clearLiveEventBindings();
expect(spec.loadFixtureCount).toBeLessThan(2);
spec.loadFixtureCount = 0;
});

View file

@ -0,0 +1,22 @@
describe("rails", function() {
describe("remote forms", function() {
beforeEach(function() {
$("#jasmine_content").html(
'<form accept-charset="UTF-8" id="form" action="/status_messages" data-remote="true" method="post">' +
'<textarea id="status_message_message" name="status_message[message]">Some status message</textarea>' +
'<input type="submit">' +
'</form>'
);
});
it("should retain form values if ajax fails", function() {
$('#form').trigger('ajax:failure');
expect($('#status_message_message').val()).not.toEqual("");
});
it("should clear form on ajax:success", function() {
$('#form').trigger('ajax:success');
expect($('#status_message_message').val()).toEqual("");
});
});
});

View file

@ -25,6 +25,7 @@ src_files:
- public/javascripts/view.js
- public/javascripts/stream.js
- public/javascripts/validation.js
- public/javascripts/rails.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.