Class: Moto::Clients::Website

Inherits:
Base
  • Object
show all
Defined in:
lib/clients/website.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#context

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from TestLogging

included

Constructor Details

This class inherits a constructor from Moto::Clients::Base

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



8
9
10
# File 'lib/clients/website.rb', line 8

def session
  @session
end

Instance Method Details

#end_runObject



27
28
29
# File 'lib/clients/website.rb', line 27

def end_run
  @session.driver.browser.close # TODO: check that it really works
end

#end_test(test) ⇒ Object



36
37
38
# File 'lib/clients/website.rb', line 36

def end_test(test)
  @session.reset_session!
end

#initObject



14
15
16
17
18
19
# File 'lib/clients/website.rb', line 14

def init
  # can be overriden
  @options = {
    capybara_backend: :selenium
  }
end

#page(p) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/clients/website.rb', line 40

def page(p)
  page_class_name = "#{self.class.name}Pages::#{p}"
  page_class_name.gsub!('Moto::', 'MotoApp::')
  if @pages[page_class_name].nil?
      a = page_class_name.underscore.split('/')
      page_path = a[1..20].join('/')
      require "#{APP_DIR}/#{page_path}"	    
    @pages[page_class_name] = page_class_name.constantize.new(self)
  end
  @pages[page_class_name]
end

#start_runObject



21
22
23
24
25
# File 'lib/clients/website.rb', line 21

def start_run
  # TODO: make session driver configurable
  @session = Capybara::Session.new(@options[:capybara_backend])
  @pages = {}
end

#start_test(test) ⇒ Object



31
32
33
34
# File 'lib/clients/website.rb', line 31

def start_test(test)
  # @context.current_test.logger.info("Hi mom, I'm opening some pages!")
  @session.reset_session!
end