Skip to content

Commit

Permalink
added throwing exception when there are problems with loading fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
velesin committed Jul 12, 2011
1 parent c41ce60 commit 34a78d4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/jasmine-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
url: url,
success: function(data) {
self.fixturesCache_[relativeUrl] = data;
},
error: function(jqXHR, status, errorThrown) {
throw Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')');
}
});
};
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/real_non_mocked_fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="real_non_mocked_fixture"></div>
32 changes: 32 additions & 0 deletions spec/suites/jasmine-jquery-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,38 @@ describe("jasmine.Fixtures", function() {
});
});

describe("jasmine.Fixtures using real AJAX call", function() {
var defaultFixturesPath;

beforeEach(function() {
defaultFixturesPath = jasmine.getFixtures().fixturesPath;
jasmine.getFixtures().fixturesPath = 'spec/fixtures';
});

afterEach(function() {
jasmine.getFixtures().fixturesPath = defaultFixturesPath;
});

describe("when fixture file exists", function() {
var fixtureUrl = "real_non_mocked_fixture.html";

it("should load content of fixture file", function() {
var fixtureContent = jasmine.getFixtures().read(fixtureUrl);
expect(fixtureContent).toEqual('<div id="real_non_mocked_fixture"></div>');
});
});

describe("when fixture file does not exist", function() {
var fixtureUrl = "not_existing_fixture";

it("should throw an exception", function() {
expect(function() {
jasmine.getFixtures().read(fixtureUrl);
}).toThrow();
});
});
});


describe("jQuery matchers", function() {
describe("when jQuery matcher hides original Jasmine matcher", function() {
Expand Down

0 comments on commit 34a78d4

Please sign in to comment.