Module: Foundry
- Defined in:
- lib/test-factory/foundry.rb
Overview
This module provides methods that instantiate the page and data classes.
Instance Method Summary collapse
-
#make(data_object_class, opts = {}) ⇒ Object
Use this for making a data object in your test steps.
-
#on(page_class, visit = false, &block) ⇒ Object
(also: #on_page)
Instantiates the supplied page class, then runs the supplied block of code.
-
#visit(page_class, &block) ⇒ Object
Using the page_url defined in the provided page_class, this method will enter that url into the browser’s address bar, then run the block of code that you specify.
-
#wait_until(timeout = 30, message = nil, &block) ⇒ Object
A helper method that takes a block of code and waits until it resolves to true.
Instance Method Details
#make(data_object_class, opts = {}) ⇒ Object
Use this for making a data object in your test steps
28 29 30 |
# File 'lib/test-factory/foundry.rb', line 28 def make data_object_class, opts={} data_object_class.new @browser, opts end |
#on(page_class, visit = false, &block) ⇒ Object Also known as: on_page
Instantiates the supplied page class, then runs the supplied block of code. Use this method when you are already on the site page you want to interact with.
17 18 19 20 21 |
# File 'lib/test-factory/foundry.rb', line 17 def on page_class, visit=false, &block @current_page = page_class.new @browser, visit block.call @current_page if block @current_page end |
#visit(page_class, &block) ⇒ Object
Using the page_url defined in the provided page_class, this method will enter that url into the browser’s address bar, then run the block of code that you specify.
9 10 11 |
# File 'lib/test-factory/foundry.rb', line 9 def visit page_class, &block on page_class, true, &block end |
#wait_until(timeout = 30, message = nil, &block) ⇒ Object
A helper method that takes a block of code and waits until it resolves to true. Useful when you need to wait for something to be on a page that’s a little more involved than a simple element (for those, you should use the #expected_element method found in the PageFactory class)
41 42 43 |
# File 'lib/test-factory/foundry.rb', line 41 def wait_until(timeout=30, =nil, &block) Object::Watir::Wait.until(timeout, , &block) end |