Skip to content

Commit

Permalink
Merge pull request #484 from apiaryio/honzajavorek/ambiguous-paramete…
Browse files Browse the repository at this point in the history
…rs-raise-exception

Ambiguous parameters raise exception (fix)
  • Loading branch information
freaz committed May 17, 2016
2 parents e842526 + 09fbbe5 commit 22c0293
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 758 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"chai": "^3.4.1",
"clone": "^1.0.0",
"coffee-script": "^1.9.1",
"dredd-transactions": "0.0.4",
"dredd-transactions": "^0.0.5",
"file": "~0.2.2",
"gavel": "0.5.2",
"glob": "^6.0.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-hooks-handlers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ yaml = require 'js-yaml'


unless process.env.CI
console.error ''' \
console.error '''\
This script is meant to be ran on Travis CI. It is not optimized (yet) for
local usage. It could mess up your Git repository.
'''
Expand Down
66 changes: 0 additions & 66 deletions src/expand-uri-template-with-parameters.coffee

This file was deleted.

7 changes: 3 additions & 4 deletions src/handle-runtime-problems.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ handleRuntimeProblems = (blueprintData) ->
if annotation.component is 'apiDescriptionParser'
ranges = blueprintUtils.warningLocationToRanges(annotation.location, apiDescriptionDocument)

message = """ \
message = """\
Parser #{annotation.type} in file '#{filename}': \
(#{annotation.type} code #{annotation.code}) #{annotation.message} \
"""
Expand All @@ -32,12 +32,11 @@ handleRuntimeProblems = (blueprintData) ->
annotation.origin.actionName
].join(' > ')

log(""" \
log("""\
Compilation #{annotation.type} in file '#{filename}': \
#{annotation.message} on #{transactionName} \
#{annotation.message} (#{transactionName}) \
""")


return new Error('Error when processing API description.') if error


Expand Down
10 changes: 5 additions & 5 deletions src/hooks-worker-client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class HooksWorkerClient
if @language == 'ruby'
@handlerCommand = 'dredd-hooks-ruby'
unless which.which @handlerCommand
msg = """ \
msg = """\
Ruby hooks handler server command not found: #{@handlerCommand}
Install ruby hooks handler by running:
$ gem install dredd_hooks
Expand All @@ -93,7 +93,7 @@ class HooksWorkerClient
else if @language == 'python'
@handlerCommand = 'dredd-hooks-python'
unless which.which @handlerCommand
msg = """ \
msg = """\
Python hooks handler server command not found: #{@handlerCommand}
Install python hooks handler by running:
$ pip install dredd_hooks
Expand All @@ -105,7 +105,7 @@ class HooksWorkerClient
else if @language == 'php'
@handlerCommand = 'dredd-hooks-php'
unless which.which @handlerCommand
msg = """ \
msg = """\
PHP hooks handler server command not found: #{@handlerCommand}
Install php hooks handler by running:
$ composer require ddelnano/dredd-hooks-php --dev
Expand All @@ -117,7 +117,7 @@ class HooksWorkerClient
else if @language == 'perl'
@handlerCommand = 'dredd-hooks-perl'
unless which.which @handlerCommand
msg = """ \
msg = """\
Perl hooks handler server command not found: #{@handlerCommand}
Install perl hooks handler by running:
$ cpanm Dredd::Hooks
Expand All @@ -127,7 +127,7 @@ class HooksWorkerClient
callback()

else if @language == 'nodejs'
msg = ''' \
msg = '''\
Hooks handler should not be used for nodejs. \
Use Dredds' native node hooks instead.
'''
Expand Down
8 changes: 0 additions & 8 deletions src/inherit-parameters.coffee

This file was deleted.

31 changes: 0 additions & 31 deletions src/validate-parameters.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion test/fixtures/apiary.apib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FORMAT: X-1A
FORMAT: 1A

# Machines API

Expand Down
40 changes: 0 additions & 40 deletions test/fixtures/warning-ambigous.apib

This file was deleted.

38 changes: 38 additions & 0 deletions test/fixtures/warning-ambiguous.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FORMAT: 1A

# Machines API
# Group Machines
# Machine [/machines/{name}]
## Retrieve Single Machine [GET]

+ Response 200 (application/json; charset=utf-8)

{
"type": "bulldozer",
"name": "willy"
}

# Machines [/machines/{?sort}]
## Retrieve All Machines [GET]

+ Response 200 (application/json; charset=utf-8)

[{
"type": "bulldozer",
"name": "willy"
}]

# Machine Types [/machine-types/]
## Create a New Machine Type [POST]

+ Request (application/json; charset=utf-8)

{
"name": "bulldozer"
}

+ Response 200 (application/json; charset=utf-8)

[{
"name": "bulldozer"
}]
37 changes: 37 additions & 0 deletions test/integration/cli/api-description-cli-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ describe 'CLI - API Description Document', ->
app.get '/machines/caterpillar', (req, res) ->
res.send {type: 'bulldozer', name: 'caterpillar'}

app.post '/machine-types', (req, res) ->
res.send [{name: 'bulldozer'}]

beforeEach (done) ->
startServer configureServer, PORT, (err, serverInfo) ->
server = serverInfo
Expand Down Expand Up @@ -102,6 +105,40 @@ describe 'CLI - API Description Document', ->
it 'should print error message to stderr', ->
assert.include dreddCommand.stderr, 'Error when reading file'

describe 'When API description is loaded with errors', ->
dreddCommand = undefined
args = [
'./test/fixtures/error-blueprint.apib'
"http://localhost:#{PORT}"
]

beforeEach (done) ->
execDredd args, (err, commandInfo) ->
dreddCommand = commandInfo
done(err)

it 'should exit with status 1', ->
assert.equal dreddCommand.exitStatus, 1
it 'should print error message to stderr', ->
assert.include dreddCommand.stderr, 'Error when processing API description'

describe 'When API description is loaded with warnings', ->
dreddCommand = undefined
args = [
'./test/fixtures/warning-ambiguous.apib'
"http://localhost:#{PORT}"
]

beforeEach (done) ->
execDredd args, (err, commandInfo) ->
dreddCommand = commandInfo
done(err)

it 'should exit with status 0', ->
assert.equal dreddCommand.exitStatus, 0
it 'should print warning to stdout', ->
assert.include dreddCommand.stdout, 'warn: Compilation warning'


describe 'When loaded from URL', ->

Expand Down
Loading

0 comments on commit 22c0293

Please sign in to comment.