Add failing specs for empty <link> elements

This commit is contained in:
Akinori MUSHA 2016-10-27 09:06:00 +09:00
parent 5f5e246552
commit 2bb97b53bc

View file

@ -8,8 +8,10 @@ describe Agents::RssAgent do
}
stub_request(:any, /github.com/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/github_rss.atom")), :status => 200)
stub_request(:any, /bad.github.com/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/github_rss.atom")).gsub(/<link [^>]+\/>/, '<link/>'), status: 200)
stub_request(:any, /SlickdealsnetFP/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/slickdeals.atom")), :status => 200)
stub_request(:any, /onethingwell.org/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/onethingwell.rss")), status: 200)
stub_request(:any, /bad.onethingwell.org/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/onethingwell.rss")).gsub(/(?<=<link>)[^<]*/, ''), status: 200)
end
let(:agent) do
@ -257,6 +259,30 @@ describe Agents::RssAgent do
event = agent.events.first
expect(event.payload['authors']).to eq([])
end
context 'with an empty link in RSS' do
before do
@valid_options['url'] = 'http://bad.onethingwell.org/rss'
end
it "does not leak :no_buffer" do
agent.check
event = agent.events.first
expect(event.payload['links']).to eq([])
end
end
context 'with an empty link in RSS' do
before do
@valid_options['url'] = "https://bad.github.com/cantino/huginn/commits/master.atom"
end
it "does not leak :no_buffer" do
agent.check
event = agent.events.first
expect(event.payload['links']).to eq([])
end
end
end
describe 'logging errors with the feed url' do