Class: RUTL::NullDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/rutl/null_driver/null_driver.rb

Overview

This is at a peer level to the webdrivers but it’s for a fake application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ NullDriver

Returns a new instance of NullDriver.



10
11
12
13
# File 'lib/rutl/null_driver/null_driver.rb', line 10

def initialize(context)
  raise 'no context' unless context.is_a?(RUTL::Element::ElementContext)
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



8
9
10
# File 'lib/rutl/null_driver/null_driver.rb', line 8

def context
  @context
end

Instance Method Details

#find_element(type, location) ⇒ Object

Return a new one of these fake things so that it can be clicked ar written to or whatever.



17
18
19
20
# File 'lib/rutl/null_driver/null_driver.rb', line 17

def find_element(type, location)
  context = RUTL::Element::ElementContext.new(interface: @context.interface)
  RUTL::Element::NullElement.new(context, type, location)
end

Cheap way to handle application.navigate.to(url) TODO: Until I care about the url and then I should ????



24
25
26
27
# File 'lib/rutl/null_driver/null_driver.rb', line 24

def navigate
  context = RUTL::Element::ElementContext.new(interface: @context.interface)
  NullDriver.new(context)
end

#quitObject

Clean out the @@variables from NullElement. Other than this, this is a placeholder to match real drivers.



38
39
40
# File 'lib/rutl/null_driver/null_driver.rb', line 38

def quit
  RUTL::Element::NullElement.clear_variables
end

#to(url) ⇒ Object

Cheap second part to naviate.to(url) calls to look like real drivers.



30
31
32
33
34
# File 'lib/rutl/null_driver/null_driver.rb', line 30

def to(url)
  result = @context.interface.find_view(url)
  @context.interface.current_view = result
  result.url
end