module SimpliTest
TODO: Clean this up with OptionsParser
Loads configuration from satelite projects
exports instance variables for various directories of interest in the gem and the satelite projects
Constants
- VERSION
Public Class Methods
chromedriver_detected?()
click to toggle source
# File lib/SimpliTest/config/local_environment.rb, line 11 def self.chromedriver_detected? installed = `chromedriver --help` rescue false installed ? true : false end
config()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 68 def config @config end
configure(opts={})
click to toggle source
#TODO: Improve the documentation below ****************************************************************
Load Order/ Dependencies
****************************************************************
********TEST PROJECTS**************** In Test Projects, first load this file Then set any config variables Then load the environments file in the @config_dir The environments file loads the steps directory Steps Directory is self sufficient (no external files need to be loaded) ************************************** ********BIN STUBS********************* The gem has one bin stub: SimpliTest This simply executes a method in the Main class with @cli_directory The Main class in the cli dir requires @helpers_dir and @tasks_dir *************************************** ********RAKE TASKS********************* Some cli commands execute rake tasks in the @tasks_dir @tasks_dir requires @helpers_dir ***************************************
*****************************************************************
end¶ ↑
# File lib/SimpliTest/config/configuration.rb, line 49 def configure(opts={}) opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym} load_configuration end
default_path_for(key)
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 54 def default_path_for(key) File.join(@config[:support_directory], 'config', "#{key.to_s}.yml") end
driver()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 85 def driver ENV['SimpliTest_DRIVER'] || @config[:settings]['DRIVER'] || 'selenium' end
driver=(name)
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 89 def driver=(name) @config[:driver]=name end
env_or_setting(setting_name)
click to toggle source
# File lib/SimpliTest/config/local_environment.rb, line 16 def self.env_or_setting(setting_name) ENV[setting_name] || SimpliTest.config_settings[setting_name] end
gems_installed?(list)
click to toggle source
# File lib/SimpliTest/config/local_environment.rb, line 2 def self.gems_installed?(list) specs = [] list.each do |gem| dep = Gem::Dependency.new(gem) specs << !dep.matching_specs.empty? end specs.uniq == [true] end
load_configuration()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 72 def load_configuration begin @config[:environments] = read_from(@config[:environments_file] || default_path_for(:environments)) @config[:pages] = read_from(@config[:pages_file] || default_path_for(:pages)) @config[:selectors] = read_from(@config[:selectors_file] || default_path_for(:selectors)) @config[:settings] = read_from(@config[:settings_file] || default_path_for(:settings)) @config[:environment] = ENV['ENVIRONMENT'] || @config[:settings]['DEFAULT_ENVIRONMENT'] || @config[:settings][:environments].values.first @valid_config_keys = @config.keys rescue Exception => e alert "There was a problem reading one of the required configuration files\n" + e.message end end
method_missing(meth, *args, &block)
click to toggle source
TODO: Using method missing despite all the reasons not to FIXME: Get rid of this
Calls superclass method
# File lib/SimpliTest/config/directory_paths.rb, line 19 def method_missing(meth, *args, &block) if match = meth.to_s.match(/^config_(.+)$/) config[match[1].to_sym] elsif match = meth.to_s.match(/^path_to_(.+)$/) instance_variable_get("@#{match[1]}") else super # You *must* call super if you don't handle the # method, otherwise you'll mess up Ruby's method # lookup. end end
mode()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 93 def mode @config[:settings]['MODE'] || 'REGULAR' end
read_from(path_to_file)
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 58 def read_from(path_to_file) begin YAML::load(IO.read(path_to_file)) rescue Errno::ENOENT alert ("Expected to find #{path_to_file} but did not find it.") rescue Psych::SyntaxError alert "#{path_to_file} YAML file contains invalid syntax. Please correct it" end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/SimpliTest/config/directory_paths.rb, line 31 def respond_to_missing?(method_name, include_private = false) method_name.to_s.start_with?('config_') || meth.to_s.start_with?('path_to_') || super end
screen_size()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 97 def screen_size ENV['SCREEN_SIZE'] || @config[:settings]['SCREEN_SIZE'] || 'Desktop' end
wait_for_page_load()
click to toggle source
# File lib/SimpliTest/config/configuration.rb, line 101 def wait_for_page_load @config[:settings]['WAIT_FOR_PAGE_LOAD'].to_i rescue 0 end