Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created Nov 15, 2010
Embed
What would you like to do?
describe 'CouchConnector'
describe 'loadDocument with mocked connection'
before
lastURL = ''
c = new connector.connector({
port: 5984,
host: 'localhost',
user: '',
password: '',
database: 'test'
})
c.connection = {
request: function(url) {
lastURL = url;
}
}
end
it 'should generate a restful URL based on a document id'
c.loadDocument('foobar')
lastURL.should.equal('/foobar')
end
it 'should generate a restful URL based on DB and Keys'
c.loadDocument({
keys: ['name', 'age'],
type: 'person'
})
lastURL.should.equal('/_view/person/by_name_age')
end
it 'should build a url with the get parameter descending'
c.loadDocument({
keys: ['name', 'age'],
type: 'person',
descending: true
})
lastURL.should.equal('/_view/person/by_name_age?descending=true')
end
it 'should build a URL with the get parameters descending and startkey'
c.loadDocument({
keys: ['name', 'age'],
type: 'person',
descending: true,
startkey: ['john', '13'],
endkey: 'foo'
})
lastURL.should.match('startkey=%5B%22john%22%2C%2213%22%5D')
lastURL.should.contain('descending=true')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment