test/aitch/response_test.rb in aitch-1.2.1 vs test/aitch/response_test.rb in aitch-1.2.2
- old
+ new
@@ -4,16 +4,18 @@
class ResponseTest < Minitest::Test
test "has body" do
register_uri(:get, "http://example.org/", body: "Hello")
response = Aitch.get("http://example.org/")
+
assert_equal "Hello", response.body
end
test "sets current url" do
register_uri(:get, "http://example.org/", body: "Hello")
response = Aitch.get("http://example.org/")
+
assert_equal "http://example.org/", response.url
end
test "parses gzip response" do
stdio = StringIO.new
@@ -37,23 +39,26 @@
end
test "returns status code" do
register_uri(:get, "http://example.org/", body: "")
response = Aitch.get("http://example.org/")
+
assert_equal 200, response.code
end
test "returns content type" do
register_uri(:get, "http://example.org/", content_type: "text/html")
response = Aitch.get("http://example.org/")
+
assert_equal "text/html", response.content_type
end
test "detects as successful response" do
register_uri(:get, "http://example.org/", content_type: "text/html")
response = Aitch.get("http://example.org/")
- assert response.success?
+
+ assert_predicate response, :success?
end
test "returns headers" do
register_uri(:get, "http://example.org/", content_type: "text/html")
headers = Aitch.get("http://example.org/").headers
@@ -72,10 +77,10 @@
test "maps missing methods to headers" do
register_uri(:get, "http://example.org/", headers: {"X-Runtime" => "0.003"})
response = Aitch.get("http://example.org/")
assert_equal "0.003", response.runtime
- assert response.respond_to?(:runtime)
+ assert_respond_to response, :runtime
end
test "raises when have no method" do
register_uri(:get, "http://example.org/")
response = Aitch.get("http://example.org/")