Permalink
Browse files

Ignoring Intellij Idea files. Adding Screw.Assets, which adds the req…

…uire and stylesheet methods.
  • Loading branch information...
1 parent dfbfdb4 commit 3916fe3b49257cbaafc00a61e9f7aa658a9e273e @btakita btakita committed Apr 27, 2008
Showing with 141 additions and 103 deletions.
  1. +3 −0 .gitignore
  2. +33 −0 lib/screw.assets.js
  3. +3 −103 spec/screwunit_spec.html
  4. +102 −0 spec/screwunit_spec.js
View
@@ -0,0 +1,3 @@
+*.iml
+*.ipr
+*.iws
View
@@ -0,0 +1,33 @@
+(function(window) {
+ window.Screw.Assets = {};
+ var required_paths = [];
+ var included_stylesheets = {};
+ Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
+ var cache_buster = parseInt(new Date().getTime()/(1*1000));
+
+ window.require = function(path_from_javascripts, onload) {
+ if(!required_paths[path_from_javascripts]) {
+ var full_path = path_from_javascripts + ".js";
+ if (Screw.Assets.use_cache_buster) {
+ full_path += '?' + cache_buster;
+ }
+ document.write("<script src='" + full_path + "' type='text/javascript'></script>");
+ if(onload) {
+ var scripts = document.getElementsByTagName('script');
+ scripts[scripts.length-1].onload = onload;
+ }
+ required_paths[path_from_javascripts] = true;
+ }
+ };
+
+ window.stylesheet = function(path_from_stylesheets) {
+ if(!included_stylesheets[path_from_stylesheets]) {
+ var full_path = path_from_stylesheets + ".css";
+ if(Screw.Assets.use_cache_buster) {
+ full_path += '?' + cache_buster;
+ }
+ document.write("<link rel='stylesheet' type='text/css' href='" + full_path + "' />");
+ included_stylesheets[path_from_stylesheets] = true;
+ }
+ };
+})(window);
View
@@ -6,110 +6,10 @@
<script src="../lib/screw.builder.js"></script>
<script src="../lib/screw.events.js"></script>
<script src="../lib/screw.behaviors.js"></script>
- <link rel="stylesheet" href="../lib/screw.css">
+ <script src="../lib/screw.assets.js"></script>
<script type="text/javascript">
- Screw.Unit(function() {
- describe('Screw.Unit', function() {
- describe("Matchers", function() {
- it("invokes the provided matcher on a call to expect", function() {
- expect(true).to(equal, true);
- expect(true).to_not(equal, false);
- });
-
- it("equal matches Arrays with the same elements", function() {
- expect([1, 2, 4]).to(equal, [1, 2, 3]);
- expect([1, 2, 3]).to_not(equal, [3, 2, 1]);
- });
- });
-
- describe('#run', function() {
- describe("A describe with a before block", function() {
- var before_invoked = false;
- before(function() {
- before_invoked = true;
- });
-
- it("invokes the before prior to an it", function() {
- expect(before_invoked).to(equal, true);
- before_invoked = false;
- });
-
- it("invokes the before prior to each it", function() {
- expect(before_invoked).to(equal, true);
- });
- });
-
- describe("A describe with two before blocks", function() {
- var invocations = [];
- before(function() {
- invocations.push('before 1');
- });
-
- before(function() {
- invocations.push('before 2');
- });
-
- it("invokes the befores in lexical order prior to each it", function() {
- expect(invocations).to(equal, ['before 1', 'before 2']);
- });
- });
-
- describe("A describe with a nested describe", function() {
- var invocations = [];
- before(function() {
- invocations = [];
- invocations.push("outermost before");
- });
-
- it("after a nested describe, does not invoke any of its befores", function() {
- expect(invocations).to(equal, ["outermost before"]);
- });
-
- describe("a nested describe", function() {
- before(function() {
- invocations.push("inner before");
- });
-
- describe("a doubly nested describe", function() {
- before(function() {
- invocations.push('innermost before');
- })
-
- it("runs befores in all ancestors prior to an it", function() {
- expect(invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
- });
-
- it("runs befores in all ancestors prior to each it", function() {
- expect(invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
- });
- });
-
- it("runs a before in the parent describe before each it", function() {
- expect(invocations).to(equal, ["outermost before", "inner before"]);
- });
- });
- });
- });
-
- describe("#selector", function() {
- describe('a describe', function() {
- it('returns a css selector that uniquely locates the describe', function() {
- $('.describe').each(function() {
- expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
- });
- });
- });
-
- describe('an it', function() {
- it('returns a css selector that uniquely locates the it', function() {
- $('.it').each(function() {
- expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
- });
- });
- });
- });
- });
- });
+ stylesheet("../lib/screw");
+ require("screwunit_spec");
</script>
</head>
<body></body>
View
@@ -0,0 +1,102 @@
+Screw.Unit(function() {
+ describe('Screw.Unit', function() {
+ describe("Matchers", function() {
+ it("invokes the provided matcher on a call to expect", function() {
+ expect(true).to(equal, true);
+ expect(true).to_not(equal, false);
+ });
+
+ it("equal matches Arrays with the same elements", function() {
+ expect([1, 2, 4]).to(equal, [1, 2, 3]);
+ expect([1, 2, 3]).to_not(equal, [3, 2, 1]);
+ });
+ });
+
+ describe('#run', function() {
+ describe("A describe with a before block", function() {
+ var before_invoked = false;
+ before(function() {
+ before_invoked = true;
+ });
+
+ it("invokes the before prior to an it", function() {
+ expect(before_invoked).to(equal, true);
+ before_invoked = false;
+ });
+
+ it("invokes the before prior to each it", function() {
+ expect(before_invoked).to(equal, true);
+ });
+ });
+
+ describe("A describe with two before blocks", function() {
+ var invocations = [];
+ before(function() {
+ invocations.push('before 1');
+ });
+
+ before(function() {
+ invocations.push('before 2');
+ });
+
+ it("invokes the befores in lexical order prior to each it", function() {
+ expect(invocations).to(equal, ['before 1', 'before 2']);
+ });
+ });
+
+ describe("A describe with a nested describe", function() {
+ var invocations = [];
+ before(function() {
+ invocations = [];
+ invocations.push("outermost before");
+ });
+
+ it("after a nested describe, does not invoke any of its befores", function() {
+ expect(invocations).to(equal, ["outermost before"]);
+ });
+
+ describe("a nested describe", function() {
+ before(function() {
+ invocations.push("inner before");
+ });
+
+ describe("a doubly nested describe", function() {
+ before(function() {
+ invocations.push('innermost before');
+ })
+
+ it("runs befores in all ancestors prior to an it", function() {
+ expect(invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
+ });
+
+ it("runs befores in all ancestors prior to each it", function() {
+ expect(invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
+ });
+ });
+
+ it("runs a before in the parent describe before each it", function() {
+ expect(invocations).to(equal, ["outermost before", "inner before"]);
+ });
+ });
+ });
+ });
+
+ describe("#selector", function() {
+ describe('a describe', function() {
+ it('returns a css selector that uniquely locates the describe', function() {
+ $('.describe').each(function() {
+ expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
+ });
+ });
+ });
+
+ describe('an it', function() {
+ it('returns a css selector that uniquely locates the it', function() {
+ $('.it').each(function() {
+ expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
+ });
+ });
+ });
+ });
+ });
+});

0 comments on commit 3916fe3

Please sign in to comment.