Skip to content

Instantly share code, notes, and snippets.

@botandrose
Created November 15, 2009 23:06
Show Gist options
  • Save botandrose/235556 to your computer and use it in GitHub Desktop.
Save botandrose/235556 to your computer and use it in GitHub Desktop.
require("spec_helper.js");
require("../../public/javascripts/accounts_new.js");
Screw.Unit(function() {
// stow the fixture (plus events) away in an iframe
var fixture_freezer = document.createElement("iframe");
$(fixture_freezer).prepend($("#fixture").clone(true));
before(function() {
// wipe out dirty dom and restore clean fixture from iframe
$("#fixture").remove();
$("#fixture", fixture_freezer).clone(true).prependTo("body");
});
describe("accounts/new initially has fields", function() {
it("should have name field", function() {
expect($("#account_name").size()).to(equal, 1);
});
});
describe("accounts/new to fail if missing name", function() {
it("should have erroneous name field", function() {
$("#account_submit").click();
expect($("div.fieldWithErrors #account_name").size()).to(equal, 1);
});
});
describe("account/new to pass if has name", function() {
it("should have no errors for name field", function() {
$("#account_name").val("Micah Geisel");
$("#account_submit").click();
expect($("div.fieldWithErrors #account_name").size()).to(equal, 0);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment