westfieldlabs / apivore

Tests your rails API against its Swagger description of end-points, models, and query parameters.
Apache License 2.0
213 stars 66 forks source link

Incorrect error message for substitute data error #33

Closed gwshaw closed 9 years ago

gwshaw commented 9 years ago

If the .yml file has this: paths: '/centres/{centre_id}/movies.{format}':

and the swagger spec has this:

apivore_setup '/centres/{centre_id}/movies.json', 'get', '200' do { 'centre_id' => @centre_id} end

(note".json" rather than {format} parameter.

The error generated is:

2) the API path /centres/{centre_id}/movies/{movie_id}.{format} method get response 200 responds with the specified models Failure/Error: path.scan(/{([^}]*)}/).each do |param| URI::InvalidURIError: No substitution data found for {centre_id} to test the path /centres/{centre_id}/movies/{movie_id}.{format}. Add it via an: apivore_setup '', '', '' do { 'centre_id' => } end block in your specs.

/Users/george/.rvm/gems/ruby-2.2.0/bundler/gems/apivore-896dcb54528e/lib/apivore/rspec_builder.rb:30:in `each'

 # /Users/george/.rvm/gems/ruby-2.2.0/bundler/gems/apivore-896dcb54528e/lib/apivore/rspec_builder.rb:30:in`apivore_build_path'
 # /Users/george/.rvm/gems/ruby-2.2.0/bundler/gems/apivore-896dcb54528e/lib/apivore/rspec_builder.rb:77:in `block (3 levels) in validate'

Either the path should not match, it should complain about the correct substitution parameter, or be silent and just use the '.json' from the supplied path.

hornc commented 9 years ago

With Apivore v1.0 the error message is now:

Swagger doc: /swagger.json does not have a documented path for /centres/{centre_id}/movies.json

which is correct.

It will now additionally alert that there is a untested path:

/centres/{centre_id}/movies.{format} is untested for response code 200 so it should be clear what the mismatch is. The user can then correct either the test or the swagger.