Class: Playwright::Props
- Inherits:
-
Array
- Object
- Array
- Playwright::Props
- Defined in:
- lib/playwright/props.rb
Overview
Playwright::Props
Props are a collection of items that are used during the test. They are accessible through the Stage and can be a unique list which is filtered with the find_or_add method. You can specify a lambda to specify how it compares existing items.
first_product = Product.first
products = Playwright::Props.new(Proc.new { |p| p.id })
2.times { products.find_or_add(first_product) }
products #=> [first_product]
Instance Attribute Summary collapse
-
#include_query ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#find_or_add(item) ⇒ Object
Finds the first item in the array or adds it to the end.
-
#initialize(include_query = nil) ⇒ Props
constructor
Creates a new prop collection with an optional lambda to determine if it has already been added from
find_or_add.
Constructor Details
#initialize(include_query = nil) ⇒ Props
Creates a new prop collection with an optional lambda to determine if it has already been added from find_or_add
20 21 22 |
# File 'lib/playwright/props.rb', line 20 def initialize(include_query = nil) @include_query = include_query end |
Instance Attribute Details
#include_query ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/playwright/props.rb', line 16 def include_query @include_query end |
Instance Method Details
#find_or_add(item) ⇒ Object
Finds the first item in the array or adds it to the end.
25 26 27 28 |
# File 'lib/playwright/props.rb', line 25 def find_or_add(item) self << item unless include?(item) || include_from_query?(item) item end |