Created
May 3, 2012 23:50
-
-
Save jordelver/2590504 to your computer and use it in GitHub Desktop.
Custom must_be_json minitest assertion / expectation for use with rack-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MiniTest::Assertions | |
def assert_content_type_is_json(response) | |
content_type = response.headers['Content-Type'] | |
assert_equal 'application/json;charset=utf-8', content_type | |
end | |
end | |
module MiniTest::Expectations | |
infect_an_assertion :assert_content_type_is_json, :must_be_json, :unary | |
end | |
# Assertion | |
assert_content_type_is_json expected, last_response | |
# Expectation | |
last_response.must_be_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment