1
0
Fork 0
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:
jgeiger 2009-03-06 05:06:02 +08:00 committed by John Nunemaker
parent acd306859d
commit 0b067f7a2c
2 changed files with 8 additions and 1 deletions

View file

@ -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

View file

@ -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