homebrew-cask-versions/test/cask/url_checker_test.rb
Roland Walker 202d6019f8 Move all code under an Hbc:: namespace
* convert existing Cask:: namespace to Hbc::
* move Homebrew-fork code under Hbc::
* move freestanding classes such as Tty and TopologicalHash under Hbc::
* recast HOMEBREW_CASK_ constants as HBC_
* modify our Homebrew Formula for backward compatibility
* devscripts and dev docs
2015-01-02 07:27:03 -05:00

33 lines
1.2 KiB
Ruby

require 'test_helper'
describe Hbc::UrlChecker do
describe "request processing" do
it "adds an error if response is empty" do
cask = TestHelper.test_cask
TestHelper.fake_response_for(cask.url, "")
checker = Hbc::UrlChecker.new(cask, TestHelper.fake_fetcher)
checker.run
checker.errors.must_include "timeout while requesting #{cask.url}"
end
it "properly populates the response code and headers from an http response" do
TestHelper.fake_response_for(TestHelper.test_cask.url, <<-RESPONSE.gsub(/^ */, ''))
HTTP/1.1 200 OK
Content-Type: application/x-apple-diskimage
ETag: "b4208f3e84967be4b078ecaa03fba941"
Content-Length: 23726161
Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT
RESPONSE
checker = Hbc::UrlChecker.new(TestHelper.test_cask, TestHelper.fake_fetcher)
checker.run
checker.response_status.must_equal 'HTTP/1.1 200 OK'
checker.headers.must_equal({
'Content-Type' => 'application/x-apple-diskimage',
'ETag' => '"b4208f3e84967be4b078ecaa03fba941"',
'Content-Length' => '23726161',
'Last-Modified' => 'Sun, 12 Aug 2012 21:17:21 GMT'
})
end
end
end