Module: Common
- Defined in:
- lib/common.rb
Constant Summary collapse
- CONFIG =
unless defined? CONFIG
YAML.load_file('config/config.yml')
Instance Method Summary collapse
- #browser ⇒ Object
- #config ⇒ Object
- #dayofweek ⇒ Object
- #env ⇒ Object
- #logfilename ⇒ Object
-
#os ⇒ Object
check RUBY_PLATFORM to determine OS.
- #regression_list(filename) ⇒ Object
- #run_acceptance_tests(reportfile) ⇒ Object
-
#test_id ⇒ Object
todo: request test id from factory or test-id api/application.
-
#testlist_constructor(regression_test_list = nil) ⇒ Object
creates the test list for this particular regression run sources of test for tests is -r & test_list or -t options.
Instance Method Details
#browser ⇒ Object
40 41 42 |
# File 'lib/common.rb', line 40 def browser CONFIG['browser'] end |
#config ⇒ Object
32 33 34 |
# File 'lib/common.rb', line 32 def config return CONFIG end |
#dayofweek ⇒ Object
44 45 46 |
# File 'lib/common.rb', line 44 def dayofweek Date.today.strftime("%A") end |
#env ⇒ Object
36 37 38 |
# File 'lib/common.rb', line 36 def env CONFIG['env'] end |
#logfilename ⇒ Object
22 23 24 25 |
# File 'lib/common.rb', line 22 def logfilename time_formatted = Time.now.strftime('%m_%d_%Y_%I_%M_%p') #EXAMPLE: 01_14_2016_11_13_AM filenametime = [time_formatted,'_regression.log'].join end |
#os ⇒ Object
check RUBY_PLATFORM to determine OS. returns string (uppercase)
49 50 51 52 53 54 55 56 57 |
# File 'lib/common.rb', line 49 def os if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil "WINDOWS" elsif (/darwin/ =~ RUBY_PLATFORM) != nil "MAC" else "LINUX" end end |
#regression_list(filename) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/common.rb', line 10 def regression_list(filename) filename = "#{Dir.pwd}" + "/#{filename}" puts "searching for #{filename}\n" if(File.exists?(filename)) result = YAML.load_file(filename) #unless defined? CONFIG else puts "\n\n#{filename} was not found. \nPlease check the file then try again.\n\n" exit(1) end result end |
#run_acceptance_tests(reportfile) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/common.rb', line 83 def run_acceptance_tests (reportfile) STDOUT.puts "Starting Test Acceptance Tests" result1, err, status = Open3.capture3('cucumber', 'tests/acceptance') # Give user feedback without going into the regression logs if err.length != 0 puts "ERROR FOUND, WRITING TO #{reportfile.path}" else puts "NO ERRORS FOUND." end STDOUT.puts "Finished Acceptance Testing" end |
#test_id ⇒ Object
todo: request test id from factory or test-id api/application
28 29 30 |
# File 'lib/common.rb', line 28 def test_id return {test_id:CONFIG['testid'], password: CONFIG['password']} end |
#testlist_constructor(regression_test_list = nil) ⇒ Object
creates the test list for this particular regression run sources of test for tests is -r & test_list or -t options
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/common.rb', line 63 def testlist_constructor (regression_test_list = nil) constructor_rspec_testlist = Array.new if (regression_test_list.nil?) spec_dir_content = Dir[Dir.pwd + "/tests/spec/*_spec.rb"] spec_dir_content.each do |test| puts "Adding... #{File.basename(test)}..." constructor_rspec_testlist.push("#{$test_dir_path}" + "#{File.basename(test)}" ) end return constructor_rspec_testlist end # case: tests passed via command line or from a test_list regression_test_list.each do |test| puts "Adding... #{File.basename(test)}..." constructor_rspec_testlist.push("#{$test_dir_path}" + "#{File.basename(test)}" ) end return constructor_rspec_testlist end |