Class: Simulacrum::Component
- Inherits:
-
Object
- Object
- Simulacrum::Component
- Includes:
- Capybara::DSL
- Defined in:
- lib/simulacrum/component.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #acceptable_delta ⇒ Object
- #candidate? ⇒ Boolean
- #candidate_path ⇒ Object
-
#capture_candidate ⇒ Object
Load up the component url and capture an image, returns a File object.
- #diff_path ⇒ Object
-
#initialize(name, options) ⇒ Component
constructor
A new instance of Component.
- #reference? ⇒ Boolean
- #reference_path ⇒ Object
- #remove_candidate ⇒ Object
- #root_path ⇒ Object
Constructor Details
#initialize(name, options) ⇒ Component
Returns a new instance of Component.
10 11 12 13 |
# File 'lib/simulacrum/component.rb', line 10 def initialize(name, ) @name = name = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/simulacrum/component.rb', line 8 def name @name end |
Instance Method Details
#acceptable_delta ⇒ Object
52 53 54 |
# File 'lib/simulacrum/component.rb', line 52 def acceptable_delta .acceptable_delta || Simulacrum.configuration.acceptable_delta end |
#candidate? ⇒ Boolean
48 49 50 |
# File 'lib/simulacrum/component.rb', line 48 def candidate? File.exists?(candidate_path) end |
#candidate_path ⇒ Object
36 37 38 |
# File 'lib/simulacrum/component.rb', line 36 def candidate_path File.join(root_path, Simulacrum.configuration.candidate_filename) end |
#capture_candidate ⇒ Object
Load up the component url and capture an image, returns a File object
16 17 18 19 20 21 22 |
# File 'lib/simulacrum/component.rb', line 16 def capture_candidate ensure_example_path visit(.url) within(capture_selector) do page.save_screenshot(candidate_path) end end |
#diff_path ⇒ Object
40 41 42 |
# File 'lib/simulacrum/component.rb', line 40 def diff_path File.join(root_path, Simulacrum.configuration.diff_filename) end |
#reference? ⇒ Boolean
44 45 46 |
# File 'lib/simulacrum/component.rb', line 44 def reference? File.exists?(reference_path) end |
#reference_path ⇒ Object
32 33 34 |
# File 'lib/simulacrum/component.rb', line 32 def reference_path File.join(root_path, Simulacrum.configuration.reference_filename) end |
#remove_candidate ⇒ Object
24 25 26 |
# File 'lib/simulacrum/component.rb', line 24 def remove_candidate FileUtils.rm(candidate_path) if candidate? end |
#root_path ⇒ Object
28 29 30 |
# File 'lib/simulacrum/component.rb', line 28 def root_path File.join(Simulacrum.configuration.images_path, name.to_s) end |