Module: Symbiont::Factory
- Defined in:
- lib/symbiont/factory.rb
Instance Method Summary collapse
-
#on(definition, visit = false, &block) ⇒ Object
(also: #on_page, #while_on)
Creates a definition context for actions.
-
#on_new(definition, &block) ⇒ Object
Creates a definition context for actions.
-
#on_view(definition, &block) ⇒ Object
(also: #on_visit)
Creates a definition context for actions and establishes the context for display.
Instance Method Details
#on(definition, visit = false, &block) ⇒ Object Also known as: on_page, while_on
Creates a definition context for actions. If an existing context exists, that context will be re-used.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/symbiont/factory.rb', line 10 def on(definition, visit = false, &block) unless @page.is_a?(definition) @page = definition.new(@browser) if @browser @page = definition.new unless @browser @page.view if visit end if @page.class.instance_variable_get(:@url_match) raise Symbiont::Errors::PageURLFromFactoryNotVerified unless @page.has_correct_url? end if @page.class.instance_variable_get(:@title) raise Symbiont::Errors::PageTitleFromFactoryNotVerified unless @page.has_correct_title? end block.call @page if block @page end |
#on_new(definition, &block) ⇒ Object
Creates a definition context for actions. Unlike the on() factory, on_new will always create a new context and will never re-use an existing one.
51 52 53 54 |
# File 'lib/symbiont/factory.rb', line 51 def on_new(definition, &block) @page = nil on(definition, &block) end |
#on_view(definition, &block) ⇒ Object Also known as: on_visit
Creates a definition context for actions and establishes the context for display.
38 39 40 |
# File 'lib/symbiont/factory.rb', line 38 def on_view(definition, &block) on(definition, true, &block) end |