Module: Foundry
- Included in:
- DataFactory
- Defined in:
- lib/test-factory/foundry.rb
Overview
This module provides methods that instantiate the page and data classes.
Instance Method Summary collapse
-
#create(data_object_class, opts = {}) ⇒ Object
An extension of the #make method that simplifies and improves the readability of your “create” step definitions by combining the make with the create.
-
#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
#create(data_object_class, opts = {}) ⇒ Object
An extension of the #make method that simplifies and improves the readability of your “create” step definitions by combining the make with the create. Of course, this requires that your data object classes properly follow the design pattern and have a #create method available.
56 57 58 59 60 |
# File 'lib/test-factory/foundry.rb', line 56 def create data_object_class, opts={} data_object = make data_object_class, opts data_object.create data_object end |
#make(data_object_class, opts = {}) ⇒ Object
Use this for making a data object in your test steps
46 47 48 |
# File 'lib/test-factory/foundry.rb', line 46 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.
34 35 36 37 38 |
# File 'lib/test-factory/foundry.rb', line 34 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.
24 25 26 |
# File 'lib/test-factory/foundry.rb', line 24 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)
72 73 74 |
# File 'lib/test-factory/foundry.rb', line 72 def wait_until(timeout=30, =nil, &block) Object::Watir::Wait.until(timeout, , &block) end |