Guest User

Untitled

a guest
Nov 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class ValidationErrorInJson < Goliath::API
  2. use Goliath::Rack::Formatters::JSON
  3. def response(env)
  4. raise Goliath::Validation::Error.new(420, 'You Must Chill')
  5. end
  6. end
  7.  
  8. describe ValidationErrorInEndpoint do
  9. let(:err) { Proc.new { fail "API request failed" } }
  10.  
  11. it 'handles Goliath::Validation::Error with the correct format response' do
  12. with_api(ValidationErrorInEndpoint) do
  13. get_request({}, err) do |c|
  14. c.response.should == '{"error":"You Must Chill"}'
  15. c.response_header.status.should == 420
  16. end
  17. end
  18. end
  19. end
Add Comment
Please, Sign In to add comment