Permalink
Browse files

Extract function into sampleCode.js

  • Loading branch information...
1 parent b5e138e commit aa04c6c225ac7f120f1cbded97a1321429f623a4 Gregor Gramlich committed Jan 16, 2012
Showing with 14 additions and 7 deletions.
  1. +9 −4 Jakefile
  2. +1 −0 browser_base/SpecRunner.html
  3. +4 −0 javascript/sampleCode.js
  4. +0 −3 spec/sampleSpec.js
View
@@ -3,12 +3,15 @@ task('default', ['runspecs']);
desc('Run all jasmine specs from the spec folder');
task('runspecs', [], function () {
+ var scripts = [
+ '../lib/jasmine-jquery/lib/jasmine-jquery.js',
+ '../javascript/sampleCode.js'
+ ];
+
var jasmineHelper = require('./node_base/jasmineHelper');
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
- var scripts = ['../lib/jquery/jquery-1.7.1.js'];
-
- jasmineHelper.loadJsDomAndJQuery(scripts, function (window) {
+ jasmineHelper.loadJsDomAndJQuery(['../lib/jquery/jquery-1.7.1.js'], function (window) {
global.jasmine = require('jasmine-node/lib/jasmine-node/index');
// jasmine-node deletes global.window, so we must set it after loading jasmine-node
@@ -17,7 +20,9 @@ task('runspecs', [], function () {
global.$ = window.jQuery;
global.jQuery = window.jQuery;
- jasmineHelper.loadInContext('../lib/jasmine-jquery/lib/jasmine-jquery.js');
+ scripts.forEach(function (script) {
+ jasmineHelper.loadInContext(script);
+ });
jasmineHelper.setJQueryMatchers();
@@ -7,6 +7,7 @@
<script type="text/javascript" src="../lib/jasmine-1.1.0/jasmine-html.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery-1.7.1.js"></script>
+ <script type="text/javascript" src="../javascript/sampleCode.js"></script>
<script type="text/javascript" src="../lib/jasmine-jquery/lib/jasmine-jquery.js"></script>
<script type="text/javascript" src="../spec/sampleSpec.js"></script>
@@ -0,0 +1,4 @@
+function makeToggler ($toggler, $toBeToggled) {
+ $toggler.click(function () {$toBeToggled.toggle();});
+}
+
View
@@ -30,9 +30,6 @@ describe('fixture handling', function () {
});
it('should apply some function', function () {
- function makeToggler ($toggler, $toBeToggled) {
- $toggler.click(function () {$toBeToggled.toggle();});
- }
loadFixtures('sampleFixture.html');
makeToggler($('#visibility-toggler'), $('#some-sample-fixture-div'));
expect($('#some-sample-fixture-div')).toBeVisible();

0 comments on commit aa04c6c

Please sign in to comment.