Skip to content

Commit

Permalink
Extract function into sampleCode.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Gramlich committed Jan 16, 2012
1 parent b5e138e commit aa04c6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();

Expand Down
1 change: 1 addition & 0 deletions browser_base/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions javascript/sampleCode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function makeToggler ($toggler, $toBeToggled) {
$toggler.click(function () {$toBeToggled.toggle();});
}

3 changes: 0 additions & 3 deletions spec/sampleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit aa04c6c

Please sign in to comment.