Module: Percy::Capybara

Defined in:
lib/percy/capybara.rb,
lib/percy/capybara/client.rb,
lib/percy/capybara/version.rb,
lib/percy/capybara/anywhere.rb,
lib/percy/capybara/httpfetcher.rb,
lib/percy/capybara/client/builds.rb,
lib/percy/capybara/client/snapshots.rb,
lib/percy/capybara/client/user_agent.rb,
lib/percy/capybara/loaders/base_loader.rb,
lib/percy/capybara/loaders/native_loader.rb,
lib/percy/capybara/loaders/sprockets_loader.rb,
lib/percy/capybara/loaders/filesystem_loader.rb,
lib/percy/capybara/loaders/ember_cli_rails_loader.rb

Defined Under Namespace

Modules: Anywhere, HttpFetcher, Loaders Classes: Client

Constant Summary collapse

VERSION =
'3.1.2'.freeze

Class Method Summary collapse

Class Method Details

.capybara_client(options = {}) ⇒ Object

See Also:



9
10
11
# File 'lib/percy/capybara.rb', line 9

def self.capybara_client(options = {})
  @capybara_client ||= Percy::Capybara::Client.new(options)
end

.disable!Object

Manually disable Percy for the current capybara client. This can also be done with the PERCY_ENABLE=0 environment variable.



52
53
54
# File 'lib/percy/capybara.rb', line 52

def self.disable!
  capybara_client.disable!
end

.finalize_buildObject

Finalize the current build.

This must be called to indicate that the build is complete after all snapshots have been taken. It will silently return if no build or snapshots were created.



38
39
40
41
# File 'lib/percy/capybara.rb', line 38

def self.finalize_build
  return unless capybara_client.build_initialized?
  capybara_client.finalize_current_build
end

.initialize_build(options = {}) ⇒ Object

Creates a new build.

This usually does not need to be called explictly because the build is automatically created the first time a snapshot is created. However, this method might be useful in situations like multi-process tests where a single build must be created before forking.



28
29
30
# File 'lib/percy/capybara.rb', line 28

def self.initialize_build(options = {})
  capybara_client.initialize_build(options)
end

.reset!Object Also known as: reset

Reset the global Percy::Capybara module state.



44
45
46
# File 'lib/percy/capybara.rb', line 44

def self.reset!
  @capybara_client = nil
end

.snapshot(page, options = {}) ⇒ Object

Parameters:

  • page (Capybara::Session)

    The Capybara page to snapshot.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :name (String)

    A unique name for the current page that identifies it across builds. By default this is the URL of the page, but can be customized if the URL does not entirely identify the current state.

See Also:



17
18
19
# File 'lib/percy/capybara.rb', line 17

def self.snapshot(page, options = {})
  capybara_client.snapshot(page, options)
end

.use_loader(loader, options = {}) ⇒ Object



56
57
58
# File 'lib/percy/capybara.rb', line 56

def self.use_loader(loader, options = {})
  capybara_client(loader: loader, loader_options: options)
end