Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Add support for path in API endpoint #45

Merged
merged 1 commit into from
Mar 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/execute-transaction.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ executeTransaction = (transaction, callback) ->
splitHeader = header.split(':')
flatHeaders[splitHeader[0]] = splitHeader[1]

if parsedUrl['path'] == "/"
fullPath = request['uri']
else
fullPath = parsedUrl['path'] + request['uri']

options =
host: parsedUrl['hostname']
port: parsedUrl['port']
path: request['uri']
path: fullPath
method: request['method']
headers: flatHeaders

Expand Down
25 changes: 23 additions & 2 deletions test/integration/cli-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,29 @@ describe "Command line interface", () ->
it 'exit status should be 0', () ->
assert.equal exitStatus, 0

describe "when executing the command and the server is responding as specified in the blueprint, endpoint with path", () ->
before (done) ->
cmd = "./bin/dredd ./test/fixtures/single_get.md http://localhost:#{PORT}/v2"

app = express()

app.get '/v2/machines', (req, res) ->
res.setHeader 'Content-Type', 'application/json'
machine =
type: 'bulldozer'
name: 'willy'
response = [machine]
res.send 200, response

server = app.listen PORT, () ->
execCommand cmd, () ->
server.close()

server.on 'close', done

it 'exit status should be 0', () ->
assert.equal exitStatus, 0

describe "when executing the command and the server is sending different response", () ->
before (done) ->
cmd = "./bin/dredd ./test/fixtures/single_get.md http://localhost:#{PORT}"
Expand Down Expand Up @@ -437,5 +460,3 @@ describe "Command line interface", () ->
it 'should display timestamps', () ->
# look for the prefix for cli output with timestamps
assert.notEqual stdout.indexOf 'Z -', -1


1 change: 0 additions & 1 deletion test/unit/execute-transaction-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@ describe 'executeTransaction(transaction, callback)', () ->
executeTransaction transaction, () ->
assert.notOk server.isDone()
done()