Module: SitePrism::DSL::Methods
- Defined in:
- lib/site_prism/dsl/methods.rb
Overview
- SitePrism::DSL::Methods
-
The meta-programmed methods for using SitePrism during runtime. This public DSL contains all the methods you will use on ‘SitePrism::Page` or `SitePrism::Section` classes
Instance Attribute Summary collapse
-
#expected_items ⇒ Object
readonly
Returns the value of attribute expected_items.
Instance Method Summary collapse
-
#element(name, *find_args) ⇒ Object
Creates an instance of a SitePrism Element - This will create several methods designed to Locate the element -> @return [Capybara::Node::Element] Check the elements presence or non-presence -> @return [Boolean] Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the element.
-
#elements(name, *find_args) ⇒ Object
Creates a enumerable instance of a SitePrism Element - This will create several methods designed to Locate the enumerable element -> @return [Capybara::Result] Check the elements presence or non-presence -> @return [Boolean] Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the elements.
-
#expected_elements(*elements) ⇒ Object
Sets the ‘expected_items` iVar on a class.
- #iframe(name, klass, *args) ⇒ Object
-
#section(name, *args, &block) ⇒ Object
Creates an instance of a SitePrism Section - This will create several methods designed to Locate the section -> @return [SitePrism::Section] Check the section presence or non-presence -> @return [Boolean] Wait for the section to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the section.
-
#sections(name, *args, &block) ⇒ Object
Creates an enumerable instance of a SitePrism Section - This will create several methods designed to Locate the sections -> @return [Array] Check the sections presence or non-presence -> @return [Boolean] Wait for the sections to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the section.
Instance Attribute Details
#expected_items ⇒ Object (readonly)
Returns the value of attribute expected_items.
11 12 13 |
# File 'lib/site_prism/dsl/methods.rb', line 11 def expected_items @expected_items end |
Instance Method Details
#element(name, *find_args) ⇒ Object
Creates an instance of a SitePrism Element - This will create several methods designed to Locate the element -> @return [Capybara::Node::Element] Check the elements presence or non-presence -> @return [Boolean] Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the element
25 26 27 28 29 30 31 32 33 |
# File 'lib/site_prism/dsl/methods.rb', line 25 def element(name, *find_args) raise_if_build_time_block_supplied(self, name, block_given?, :element) build(:element, name, *find_args) do define_method(name) do |*runtime_args, &runtime_block| raise_if_runtime_block_supplied(self, name, runtime_block, :element) _find(*merge_args(find_args, runtime_args)) end end end |
#elements(name, *find_args) ⇒ Object
Creates a enumerable instance of a SitePrism Element - This will create several methods designed to Locate the enumerable element -> @return [Capybara::Result] Check the elements presence or non-presence -> @return [Boolean] Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the elements
40 41 42 43 44 45 46 47 48 |
# File 'lib/site_prism/dsl/methods.rb', line 40 def elements(name, *find_args) raise_if_build_time_block_supplied(self, name, block_given?, :elements) build(:elements, name, *find_args) do define_method(name) do |*runtime_args, &runtime_block| raise_if_runtime_block_supplied(self, name, runtime_block, :elements) _all(*merge_args(find_args, runtime_args)) end end end |
#expected_elements(*elements) ⇒ Object
Sets the ‘expected_items` iVar on a class. This property is used in conjunction with `all_there?` to provide a way of granularising the check made to only interrogate a sub-set of DSL defined items
16 17 18 |
# File 'lib/site_prism/dsl/methods.rb', line 16 def expected_elements(*elements) @expected_items = elements end |
#iframe(name, klass, *args) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/site_prism/dsl/methods.rb', line 82 def iframe(name, klass, *args) raise_if_build_time_block_supplied(self, name, block_given?, :elements) element_find_args = deduce_iframe_element_find_args(args) scope_find_args = deduce_iframe_scope_find_args(args) build(:iframe, name, *element_find_args) do define_method(name) do |&block| raise MissingBlockError unless block within_frame(*scope_find_args) { block.call(klass.new) } end end end |
#section(name, *args, &block) ⇒ Object
Creates an instance of a SitePrism Section - This will create several methods designed to Locate the section -> @return [SitePrism::Section] Check the section presence or non-presence -> @return [Boolean] Wait for the section to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the section
55 56 57 58 59 60 61 62 63 |
# File 'lib/site_prism/dsl/methods.rb', line 55 def section(name, *args, &block) section_class, find_args = (args, &block) build(:section, name, *find_args) do define_method(name) do |*runtime_args, &runtime_block| section_element = _find(*merge_args(find_args, runtime_args)) section_class.new(self, section_element, &runtime_block) end end end |
#sections(name, *args, &block) ⇒ Object
Creates an enumerable instance of a SitePrism Section - This will create several methods designed to Locate the sections -> @return [Array] Check the sections presence or non-presence -> @return [Boolean] Wait for the sections to be present or not -> @return [TrueClass, SitePrism::Error] Validate certain properties about the section
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/site_prism/dsl/methods.rb', line 70 def sections(name, *args, &block) section_class, find_args = (args, &block) build(:sections, name, *find_args) do define_method(name) do |*runtime_args, &runtime_block| raise_if_runtime_block_supplied(self, name, runtime_block, :sections) _all(*merge_args(find_args, runtime_args)).map do |element| section_class.new(self, element) end end end end |