Skip to content

Commit

Permalink
#19 change to go directly to parse stub
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Sep 25, 2012
1 parent 5a0a704 commit d4ff785
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/OAuth2Provider_tests.js
Expand Up @@ -15,13 +15,14 @@ describe('OAuth2Provider', function(){
var crypt_key = '123131',
sign_key = 'asdfasdfas';

// stub returned serializer so that can mock it
this.stubSerializer = {
parse : sinon.stub()
};
// create parse stub that will be used to parse incoming requests
this.parseStub = sinon.stub();

// stub method to return object that has parseStub for parser
this.createSerializerStub = sinon.stub(serializer, 'createSecureSerializer');
this.createSerializerStub.withArgs(crypt_key, sign_key).returns(this.stubSerializer);
this.createSerializerStub.withArgs(crypt_key, sign_key).returns({
parse : this.parseStub
});

this.oAuth2Provider = createOauth2Provider();
});
Expand All @@ -40,9 +41,10 @@ describe('OAuth2Provider', function(){
dateString = '01/05/2012',
extra_data = 'wadfasdfasfasdfas';

// below data result from serialization
var expectedParsedData = [user_id, client_id, dateString, extra_data];
// setup serializer so that returns above data for that access token
this.stubSerializer.parse.withArgs(access_token).returns(expectedParsedData);
this.parseStub.withArgs(access_token).returns(expectedParsedData);

this.oAuth2Provider.emit = sinon.spy();

Expand Down Expand Up @@ -77,7 +79,7 @@ describe('OAuth2Provider', function(){
var errorMessage = 'could not parse data',
access_token = '123412341234124312341234';
// change serializer to throw an error with the access token
this.stubSerializer.parse.withArgs(access_token).throws({ message : errorMessage});
this.parseStub.withArgs(access_token).throws({ message : errorMessage});

var req = {
query : {
Expand Down

0 comments on commit d4ff785

Please sign in to comment.