Sha256: e2eb1e9e7ab8f092cdeaa5c0de801d5ad9dac11703b417e1fdc6f4fa4e5312ff
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
require 'retriever' describe 'Fetch' do describe '#good_response?' do let(:r) do Retriever::Fetch.new('http://www.yahoo.com', {}) end let(:resp) do {} end let(:nil_response) do r.good_response?(nil,'http://www.yahoo.com') end let(:unsuccessful_resp) do resp.stub(:response_header).and_return(resp) resp.stub(:redirection?).and_return(false) resp.stub(:successful?).and_return(false) resp.stub(:server_error?).and_return(false) resp.stub(:client_error?).and_return(false) r.good_response?(resp,'http://www.yahoo.com') end let(:redir_resp) do resp.stub(:response_header).and_return(resp) resp.stub(:redirection?).and_return(true) resp.stub(:location).and_return('http://www.google.com') r.good_response?(resp,'http://www.yahoo.com') end let(:bad_content_type_resp) do resp.stub(:response_header).and_return(resp) resp.stub(:redirection?).and_return(false) resp.stub(:successful?).and_return(true) resp['CONTENT_TYPE'] = 'image/jpeg' r.good_response?(resp,'http://www.yahoo.com') end let(:success_resp) do resp.stub(:response_header).and_return(resp) resp.stub(:redirection?).and_return(false) resp.stub(:successful?).and_return(true) resp['CONTENT_TYPE'] = 'text/html' r.good_response?(resp,'http://www.yahoo.com') end it 'returns false if the response is empty' do expect(nil_response).to eq(false) end it 'returns false on unsuccessful connection' do expect(unsuccessful_resp).to eq(false) end it 'returns false on redirecting host' do expect(redir_resp).to eq(false) end it 'returns false on non-visitable content type' do expect(bad_content_type_resp).to eq(false) end it 'returns true otherwise' do expect(success_resp).to eq(true) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyretriever-1.3.0 | spec/retriever_spec.rb |