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

read_resource should validate JSON before returning response #13

Open
josephruscio opened this issue Sep 13, 2013 · 0 comments
Open

read_resource should validate JSON before returning response #13

josephruscio opened this issue Sep 13, 2013 · 0 comments

Comments

@josephruscio
Copy link
Owner

something like:

    def assert_valid_json(response, msg = nil)
      full_message = build_message(msg, "response should be valid JSON")
      assert_block(full_message) do
        parsable = begin
                     JSON.parse last_response.body
                     true
                   rescue JSON::ParserError
                     false
                   end

        parsable && last_response.header['Content-Type'].include?("application/json")
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant