Class: Percy::Capybara::Loaders::NativeLoader

Inherits:
BaseLoader
  • Object
show all
Defined in:
lib/percy/capybara/loaders/native_loader.rb

Overview

Resource loader that uses the native Capybara browser interface to discover resources. This loader uses JavaScript to discover page resources, so specs must be tagged with “js: true” because the default Rack::Test driver does not support executing JavaScript.

Constant Summary collapse

PATH_REGEX =
/\A\/[^\\s\"']*/
DATA_URL_REGEX =
/\Adata:/
LOCAL_HOSTNAMES =
[
  'localhost',
  '127.0.0.1',
  '0.0.0.0',
].freeze

Constants inherited from BaseLoader

BaseLoader::MAX_FILESIZE_BYTES, BaseLoader::SKIP_RESOURCE_EXTENSIONS, BaseLoader::URL_REGEX

Instance Attribute Summary

Attributes inherited from BaseLoader

#page

Instance Method Summary collapse

Methods inherited from BaseLoader

#_find_files, #_resources_from_dir, #_uri_join

Constructor Details

#initialize(options = {}) ⇒ NativeLoader

Returns a new instance of NativeLoader.



20
21
22
23
24
25
26
# File 'lib/percy/capybara/loaders/native_loader.rb', line 20

def initialize(options = {})
  super(options)

  @asset_hostnames = options[:asset_hostnames] || []
  @assets_from_stylesheets = options[:include_assets_from_stylesheets] || :all
  @assets_from_stylesheets = ->(_) { true } if @assets_from_stylesheets == :all
end

Instance Method Details

#build_resourcesObject



37
38
39
# File 'lib/percy/capybara/loaders/native_loader.rb', line 37

def build_resources
  []
end

#snapshot_resourcesObject



28
29
30
31
32
33
34
35
# File 'lib/percy/capybara/loaders/native_loader.rb', line 28

def snapshot_resources
  resources = []
  resources << root_html_resource
  resources += _get_css_resources
  resources += _get_image_resources
  resources += iframes_resources
  resources
end