Permalink
Browse files

Fixed race condition.

  • Loading branch information...
1 parent 6341923 commit 23c7d965bc93d4caa82eb2be10f3be2a9075fdd1 @btakita btakita committed Apr 29, 2008
Showing with 13 additions and 12 deletions.
  1. +13 −12 lib/screw.builder.js
View
@@ -1,10 +1,5 @@
var Screw = {
Unit: function(suite) {
- var contents = suite.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
- var suite = new Function("matchers", "specifications",
- "with (specifications) { with (matchers) { " + contents + " } }"
- );
-
if(!Screw.root_element) {
Screw.root_element = $('<div class="describe">');
Screw.root_element
@@ -17,13 +12,19 @@ var Screw = {
}
Screw.last_suite = suite;
- $(function() {
- $('body').append(Screw.root_element);
- suite.call(this, Screw.Matchers, Screw.Specifications);
- if(Screw.last_suite == suite) {
- $(Screw).trigger('loaded')
- }
- })
+ Screw.root_element.ready(function() {
+ $(function() {
+ $('body').append(Screw.root_element);
+ var contents = suite.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
+ var eval_suite = new Function("matchers", "specifications",
+ "with (specifications) { with (matchers) { " + contents + " } }"
+ );
+ eval_suite.call(this, Screw.Matchers, Screw.Specifications);
+ if(Screw.last_suite == suite) {
+ $(Screw).trigger('loaded')
+ }
+ })
+ });
},
root_element: null,
last_suite: null,

0 comments on commit 23c7d96

Please sign in to comment.