Improves detection of WP Version, Plugins etc by checking 404

This commit is contained in:
erwanlr
2019-10-31 19:56:05 +00:00
parent 85aa9f61cd
commit 6b5e016770
44 changed files with 456 additions and 146 deletions

View File

@@ -0,0 +1,47 @@
# frozen_string_literal: true
shared_examples 'App::Finders::WpItems::UrlsInPage' do
before do
stub_request(:get, page_url).to_return(body: File.read(fixtures.join(file)))
end
describe '#items_from_links' do
context 'when none found' do
let(:file) { 'none.html' }
it 'returns an empty array' do
expect(finder.items_from_links(type)).to eql([])
end
end
context 'when found' do
let(:file) { 'found.html' }
it 'returns the expected array' do
expect(finder.target).to receive(:content_dir).at_least(1).and_return('wp-content')
expect(finder.items_from_links(type, uniq_links)).to eql expected_from_links
end
end
end
describe '#items_from_codes' do
before { expect(finder.target).to receive(:content_dir).at_least(1).and_return('wp-content') }
context 'when none found' do
let(:file) { 'none.html' }
it 'returns an empty array' do
expect(finder.items_from_codes(type)).to eql([])
end
end
context 'when found' do
let(:file) { 'found.html' }
it 'returns the expected array' do
expect(finder.items_from_codes(type, uniq_codes)).to eql expected_from_codes
end
end
end
end