mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
only show the acceptable format one time per format on exception
Signed-off-by: John Nunemaker <nunemaker@gmail.com>
This commit is contained in:
parent
acd306859d
commit
0b067f7a2c
2 changed files with 8 additions and 1 deletions
|
@ -102,7 +102,7 @@ module HTTParty
|
|||
# format :json
|
||||
# end
|
||||
def format(f)
|
||||
raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.join(', ')}" unless AllowedFormats.value?(f)
|
||||
raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.uniq.join(', ')}" unless AllowedFormats.value?(f)
|
||||
default_options[:format] = f
|
||||
end
|
||||
|
||||
|
|
|
@ -159,6 +159,13 @@ describe HTTParty do
|
|||
@klass.format :foobar
|
||||
end.should raise_error(HTTParty::UnsupportedFormat)
|
||||
end
|
||||
|
||||
it 'should only print each format once with an exception' do
|
||||
lambda do
|
||||
@klass.format :foobar
|
||||
end.should raise_error(HTTParty::UnsupportedFormat, "Must be one of: json, xml, html, yaml, plain")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "with explicit override of automatic redirect handling" do
|
||||
|
|
Loading…
Add table
Reference in a new issue