module SpecTest

Constants

VERSION

Attributes

platform[R]

@return [TerminusSpec::Platforms::WatirWebDriver::PlatformObject] the platform object @return [TerminusSpec::Platforms::SeleniumWebDriver::PlatformObject] the platform object

Public Class Methods

included(caller) click to toggle source

This makes sure that any page classes that include SpecTest will be given access to the generator and encloser methods based on web objects that are declared in the page class.

# File lib/spectest.rb, line 23
def self.included(caller)
  caller.extend SpecTest::Generators
  caller.extend SpecTest::Enclosers
end
new(browser, visit=nil) click to toggle source
# File lib/spectest.rb, line 28
def initialize(browser, visit=nil)
  @browser = browser
  establish_platform_driver_for browser
  goto if visit && respond_to?(:goto)
end
trace(message, level=1) click to toggle source
# File lib/spectest/logger.rb, line 2
def self.trace(message, level=1)
  puts("*" * level + " #{message}") if ENV['TRACE'] == 'on'
end
version_info() click to toggle source
# File lib/spectest.rb, line 16
def self.version_info
  "SpecTest version #{SpecTest::VERSION}"
end

Public Instance Methods

is_enclosed_by(identifier, encloser=nil, &block) click to toggle source

Used to identify a web object as existing within an enclosing object like a frame or an iframe. There is a duplicate method in enclosers.rb. This method needs to be here so that test steps can be placed in an enclosed context.

@param [String] identifier how an encloser will be referred to @param encloser a parent encloser that is passed from a previous call @param [optional] block that contains calls to web objects within the encloser

# File lib/spectest.rb, line 64
def is_enclosed_by(identifier, encloser=nil, &block)
  encloser = [] if encloser.nil?
  encloser << identifier
  block.call(encloser)
end
navigate_to(url) click to toggle source

Navigate to the specified URL. The URL can be specified as a domain address or as a file-based link. @param [String] url the full URL to navigate to

text() click to toggle source

Returns the text of the current page.

# File lib/spectest.rb, line 52
def text
  @platform.text
end
title() click to toggle source

Returns the title of the current page as displayed in the browser.

# File lib/spectest.rb, line 47
def title
  @platform.title
end

Private Instance Methods

establish_platform_driver_for(browser) click to toggle source
# File lib/spectest.rb, line 72
def establish_platform_driver_for(browser)
  @platform = platform_for browser, SpecTest::Platforms.list
end
process_block(&block) click to toggle source
# File lib/spectest.rb, line 76
def process_block(&block)
  block.arity == 1 ? block.call(self) : self.instance_eval(&block)
end