Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Extract function into sampleCode.js

  • Loading branch information...
commit aa04c6c225ac7f120f1cbded97a1321429f623a4 1 parent b5e138e
Gregor Gramlich authored January 17, 2012
13  Jakefile
@@ -3,12 +3,15 @@ task('default', ['runspecs']);
3 3
 
4 4
 desc('Run all jasmine specs from the spec folder');
5 5
 task('runspecs', [], function () {
  6
+    var scripts = [
  7
+        '../lib/jasmine-jquery/lib/jasmine-jquery.js',
  8
+        '../javascript/sampleCode.js'
  9
+    ];
  10
+
6 11
     var jasmineHelper = require('./node_base/jasmineHelper');
7 12
     if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
8 13
     
9  
-    var scripts = ['../lib/jquery/jquery-1.7.1.js'];
10  
-    
11  
-    jasmineHelper.loadJsDomAndJQuery(scripts, function (window) {
  14
+    jasmineHelper.loadJsDomAndJQuery(['../lib/jquery/jquery-1.7.1.js'], function (window) {
12 15
         global.jasmine = require('jasmine-node/lib/jasmine-node/index');
13 16
         
14 17
         // jasmine-node deletes global.window, so we must set it after loading jasmine-node
@@ -17,7 +20,9 @@ task('runspecs', [], function () {
17 20
         global.$ = window.jQuery;
18 21
         global.jQuery = window.jQuery;
19 22
         
20  
-        jasmineHelper.loadInContext('../lib/jasmine-jquery/lib/jasmine-jquery.js');
  23
+        scripts.forEach(function (script) {
  24
+            jasmineHelper.loadInContext(script);
  25
+        });
21 26
         
22 27
         jasmineHelper.setJQueryMatchers();
23 28
         
1  browser_base/SpecRunner.html
@@ -7,6 +7,7 @@
7 7
   <script type="text/javascript" src="../lib/jasmine-1.1.0/jasmine-html.js"></script>
8 8
 
9 9
   <script type="text/javascript" src="../lib/jquery/jquery-1.7.1.js"></script>
  10
+  <script type="text/javascript" src="../javascript/sampleCode.js"></script>
10 11
 
11 12
   <script type="text/javascript" src="../lib/jasmine-jquery/lib/jasmine-jquery.js"></script>
12 13
   <script type="text/javascript" src="../spec/sampleSpec.js"></script>
4  javascript/sampleCode.js
... ...
@@ -0,0 +1,4 @@
  1
+function makeToggler ($toggler, $toBeToggled) {
  2
+    $toggler.click(function () {$toBeToggled.toggle();});
  3
+}
  4
+
3  spec/sampleSpec.js
@@ -30,9 +30,6 @@ describe('fixture handling', function () {
30 30
     });
31 31
     
32 32
     it('should apply some function', function () {
33  
-        function makeToggler ($toggler, $toBeToggled) {
34  
-            $toggler.click(function () {$toBeToggled.toggle();});
35  
-        }
36 33
         loadFixtures('sampleFixture.html');
37 34
         makeToggler($('#visibility-toggler'), $('#some-sample-fixture-div'));
38 35
         expect($('#some-sample-fixture-div')).toBeVisible();

0 notes on commit aa04c6c

Please sign in to comment.
Something went wrong with that request. Please try again.