Skip to content

Commit

Permalink
only show the acceptable format one time per format on exception
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunemaker <nunemaker@gmail.com>
  • Loading branch information
jgeiger authored and jnunemaker committed Mar 30, 2009
1 parent acd3068 commit 0b067f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httparty.rb
Expand Up @@ -102,7 +102,7 @@ def cookies(h={})
# 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

Expand Down
7 changes: 7 additions & 0 deletions spec/httparty_spec.rb
Expand Up @@ -159,6 +159,13 @@ def second_method
@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
Expand Down

0 comments on commit 0b067f7

Please sign in to comment.