mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Better error message for missing let
I've run into this problem a number of times. The original error message is actually a `NoMethodError` and it's not always immediately clear what the solution is, particuarly if you're new to rspec or rswag Wanted to see if this kind of behavior is something that the rswag team would be interested in adopting. I have a few other of these in mind (will do as small PRs, with tests)
This commit is contained in:
@@ -160,6 +160,21 @@ module Rswag
|
||||
end
|
||||
end
|
||||
|
||||
context 'missing body parameter' do
|
||||
before do
|
||||
metadata[:operation][:parameters] = [{ name: 'comment', in: :body, schema: { type: 'object' } }]
|
||||
allow(example).to receive(:comment).and_raise(NoMethodError, "undefined method 'comment'")
|
||||
allow(example).to receive(:respond_to?).with(:'Content-Type')
|
||||
allow(example).to receive(:respond_to?).with('comment').and_return(false)
|
||||
end
|
||||
|
||||
it 'uses the referenced metadata to build the request' do
|
||||
expect do
|
||||
request[:payload]
|
||||
end.to raise_error(Rswag::Specs::MissingParameterError, /Missing parameter comment/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'form payload' do
|
||||
before do
|
||||
metadata[:operation][:consumes] = ['multipart/form-data']
|
||||
|
||||
Reference in New Issue
Block a user