spec/lib/percy/capybara/loaders/base_loader_spec.rb in percy-capybara-2.4.2 vs spec/lib/percy/capybara/loaders/base_loader_spec.rb in percy-capybara-2.4.3

- old
+ new

@@ -4,10 +4,19 @@ def self.call(_env) [200, {}, File.read(IFRAME_PATH)] end end +# Mock dependency on Poltergeist so we can test an error class. +module Capybara + module Poltergeist + class Error < StandardError; end + class ClientError < Error; end + class FrameNotFound < ClientError; end + end +end + RSpec.describe Percy::Capybara::Loaders::BaseLoader do let(:loader) { described_class.new } describe '#root_html_resource', type: :feature, js: true do it 'includes the root DOM HTML' do @@ -33,9 +42,17 @@ expect(resources.size).to eq(1) # doesn't include iframe to remote host last_resource = resources.last expect(last_resource.resource_url).to eq('iframe.html') expect(last_resource.mimetype).to eq('text/html') expect(last_resource.content).to include('Inside iframe') + end + it 'skips poltergeist frame not found errors' do + visit '/test-iframe.html' + + expect(page).to receive(:within_frame).twice.and_raise(Capybara::Poltergeist::FrameNotFound) + loader = described_class.new(page: page) + resources = loader.iframes_resources + expect(resources.size).to eq(0) end end describe '#build_resources' do it 'raises a NotImplementedError' do expect { loader.build_resources }.to raise_error(NotImplementedError)