Class: Capybara::Storyboard::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/storyboard/configuration.rb

Overview

Holds the user-overridable settings: where screenshots are rooted and which policy decides whether to capture. Defaults are resolved lazily in the getters so that merely constructing (or loading the gem) never reads ENV or builds the default policy — that keeps the "disabled -> zero overhead" contract intact.

Constant Summary collapse

DEFAULT_PAGE_STABILITY_INTERVAL =
0.5
DEFAULT_PAGE_STABILITY_MAX_ATTEMPTS =
10
DEFAULT_PAGE_STABILITY_EXCLUDED_ANIMATIONS =
[].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#page_stability_excluded_animationsObject

Animation names ignored by the running-animation check (e.g. infinite spinners). Returns the default (empty list) until overridden.



65
66
67
# File 'lib/capybara/storyboard/configuration.rb', line 65

def page_stability_excluded_animations
  @page_stability_excluded_animations || DEFAULT_PAGE_STABILITY_EXCLUDED_ANIMATIONS
end

#page_stability_intervalObject

Seconds to wait between page-stability polls, and the same value the DOM-quiet check must exceed. Returns the default (0.5) until overridden.



53
54
55
# File 'lib/capybara/storyboard/configuration.rb', line 53

def page_stability_interval
  @page_stability_interval || DEFAULT_PAGE_STABILITY_INTERVAL
end

#page_stability_max_attemptsObject

Maximum number of stability polls before giving up (and warning rather than raising). Returns the default (10) until overridden.



59
60
61
# File 'lib/capybara/storyboard/configuration.rb', line 59

def page_stability_max_attempts
  @page_stability_max_attempts || DEFAULT_PAGE_STABILITY_MAX_ATTEMPTS
end

#policyObject



41
42
43
# File 'lib/capybara/storyboard/configuration.rb', line 41

def policy
  @policy ||= Capybara::Storyboard.default_policy
end

Instance Method Details

#output_dirObject

The output root under which Session appends /. Returns the default (/tmp/screenshots) until overridden.



29
30
31
# File 'lib/capybara/storyboard/configuration.rb', line 29

def output_dir
  @output_dir || default_output_dir
end

#output_dir=(value) ⇒ Object

Accepts nil (restore default) or any value coercible to a Pathname. A non-nil value is stored as a Pathname because Session calls #join on it; a relative path is kept as-is (resolved against the cwd, which is Rails.root under normal use).



37
38
39
# File 'lib/capybara/storyboard/configuration.rb', line 37

def output_dir=(value)
  @output_dir = value.nil? ? nil : Pathname(value)
end

#reset_policy!Object

Equivalent to self.policy = nil; named for readable after hooks that prevent a custom policy from leaking into later examples.



47
48
49
# File 'lib/capybara/storyboard/configuration.rb', line 47

def reset_policy!
  @policy = nil
end