forked from gmoeck/fictum
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add a (yet failing) test for correct error state
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
43 changes: 43 additions & 0 deletions
43
frameworks/foundation/tests/integration/requested_error_state.js
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
describe('Scenario: Requesting with a non 200 status code', function() { | ||
describe('Given I have setup Fictum', function() { | ||
beforeEach(function() { | ||
Fictum.setup(); | ||
}); | ||
|
||
afterEach(function() { | ||
Fictum.teardown(); | ||
}); | ||
|
||
describe('And a URL that I want to stub', function() { | ||
var url; | ||
beforeEach(function() { | ||
url = '/broken'; | ||
}); | ||
|
||
describe('When I register that URL with a non 200 status code', function() { | ||
beforeEach(function() { | ||
Fictum.registerUrl(url, "You made response kitty cry!", { status: 500 } ); | ||
}); | ||
|
||
describe('And I make a request to a url asking for JSON that matches the registered URL regular expression', function() { | ||
var request, response; | ||
beforeEach(function() { | ||
request = SC.Request.getUrl('/broken') | ||
response = request.send(); | ||
waitsFor(function() { | ||
return response.get('status') !== -100; | ||
}); | ||
}); | ||
|
||
it('Then I should receive the registered response in JSON', function() { | ||
|
||
expect(response.get('body')).toEqual("You made response kitty cry!"); | ||
expect(response.get('status')).toEqual(500); | ||
expect(response.get('isError')).toEqual(true); | ||
expect(SC.ok(response)).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |