Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing an :error inside a middleware doesn't respect the format settings. #375

Closed
dblock opened this issue Mar 29, 2013 · 0 comments
Closed

Comments

@dblock
Copy link
Member

dblock commented Mar 29, 2013

      it 'raised :error from middleware' do
        middleware = Class.new(Grape::Middleware::Base) do
          def before
            throw :error, message: "Unauthorized", status: 42
          end
        end
        subject.format :xml
        subject.use middleware
        subject.get do

        end
        get "/"
        last_response.status.should == 42
        last_response.body.should == <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<error>
  <message>Unauthorized</message>
</error>
XML
      end

The format selected is :txt.

@dblock dblock closed this as completed in d510892 Mar 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant