Created
November 21, 2013 16:18
-
-
Save FilmKnurd/7584726 to your computer and use it in GitHub Desktop.
Revisions
-
FilmKnurd created this gist
Nov 21, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ // Install jquery-mockjax into vendor // file: /app/index.html <!-- @if tests=true --> <link rel="stylesheet" href="/vendor/qunit/qunit/qunit.css"> <script src="/vendor/qunit/qunit/qunit.js"></script> <script src="/vendor/jquery-mockjax/jquery.mockjax.js"></script> // And add it to karma.conf // file: karma.conf.js files = [ ... 'vendor/jquery-mockjax/jquery.mockjax.js', ... ] // Create helper to stub endpoints // file: /tests/test_helpers.js function stubEndpointForHttpRequest(url, json) { $.mockjax({ url: url, dataType: 'json', responseText: json }); } window.stubEndpointForHttpRequest = stubEndpointForHttpRequest; // Configure mockjax // file: /tests/helpers/start_app.js window.$.mockjaxSettings.logging = false; window.$.mockjaxSettings.responseTime = 0; // Use in tests // file: /tests/acceptance/some_test.js test('some test', function(){ stubEndpointForHttpRequest('/api/some/route/here', {...}); expect(1); visit('/').then(function(){ ok(true); }); });