Rename response_examples to examples for consistent DSL

Special handling `examples` invocation with no parameters to avoid
overriding the `examples` method of rspec-core ExampleGroup
This commit is contained in:
vinhbachsy
2016-10-19 03:04:03 +08:00
parent 5ea97a4278
commit 0b0acfe4c7
4 changed files with 28 additions and 5 deletions

View File

@@ -61,7 +61,11 @@ module Rswag
metadata[:response][:headers][name] = attributes
end
def response_examples(example)
# NOTE: Similar to 'description', 'examples' need to handle the case when
# being invoked with no params to avoid overriding 'examples' method of
# rspec-core ExampleGroup
def examples(example = nil)
return super() if example.nil?
metadata[:response][:examples] = example
end