Skip to content

Instantly share code, notes, and snippets.

@dougal
Created December 14, 2009 23:07
Show Gist options
  • Save dougal/256531 to your computer and use it in GitHub Desktop.
Save dougal/256531 to your computer and use it in GitHub Desktop.
Transactions for blue_ridge

Instead of manually working out what to roll back in before() or after() why not reset the whole thing? Below is my outline for doing such.

This may be slightly slower. I initially thought a lot slower, but then I discovered I had changed something else in my code that caused a lot of slowdowns. On going back to the original setup it was barely any slower.

There may be downsides I haven’t thought of yet.

[...]
<body>
<div id="inner">
<!-- Fixture stuff goes here -->
</div>
</body>
[...]
Foo = {
init : function(){
// Put all your initialization in here, so we can call it externally.
}
}
$(function(){
Foo.init()
})
require("spec_helper.js")
require("../../public/javascripts/my_js.js")
Screw.Unit(function(){
var contents = null
before(function(){
if (contents == null) {
contents = $('#inner').html()
}
else { // This saves us reloading everything one-time.
$('#inner *').unbind()
$('#inner').html(contents)
Foo.init()
}
})
// Descriptions etc go here
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment