watir_testframework 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34c7d0e863bc56e244d45303c46d8a357de22b23
4
+ data.tar.gz: bb31d0d7ca68a6d9bc7de61297367791a701ec7f
5
+ SHA512:
6
+ metadata.gz: d7322e76f2e7f86579243cf3cdf8a8db9060fcaa0838274570bb6fd4c2a4235f5967922306305cc473e1761a25254099848cd6cc75032e83c1391ddb7c2c689e
7
+ data.tar.gz: 5aae00757e1065cf7e8918b0ffc0be2969482a8ee35234f11873f8bc6acdaccff97f4f1ab2226c4874d68c053d04c62eb5a279347974408c5920dcad96977508
Binary file
data/bin/runregress ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ require "watir_testframework/version"
3
+ require 'open3'
4
+ require 'optparse'
5
+ require 'common'
6
+ require 'setup'
7
+ include Common
8
+ include Setup
9
+ puts "Running: 'WatirTestframework: version:#{WatirTestframework::VERSION}'\n\n"
10
+
11
+ opts = Setup::cml_options #Lets grab the CommandLine Options
12
+
13
+ unless opts[:projectname].nil?
14
+ binpath = File.expand_path(File.dirname(__FILE__)) + "\/"
15
+ Setup::unbundle_and_untar(binpath, opts[:projectname])
16
+ exit(0)
17
+ end
18
+
19
+ if (opts[:regression_file])
20
+ regressionlist = Common::regression_list(opts[:regression_file])
21
+ end
22
+
23
+ if ( regressionlist.nil? && opts[:testlist].nil? )
24
+ # zero tests passed on cli, so use all the tests found
25
+ rspec_testlist = Common::testlist_constructor (nil)
26
+ else
27
+ # combine anything from regression file and/or test params
28
+ rl = regressionlist ? regressionlist['test_list'] : []
29
+ tl = opts[:testlist] ? opts[:testlist] : []
30
+ rspec_testlist = Common::testlist_constructor (rl.concat(tl))
31
+ end
32
+
33
+ puts "Preparing: #{rspec_testlist.length} tests for this regression\n\n"
34
+
35
+ rspec_testlist.map { |test| if !(test.include?('.rb')) then test.concat('.rb') end }
36
+
37
+ rspec_testlist.each do |test|
38
+ test = Dir.pwd + '/tests/spec/'.concat(test)
39
+ if !File.exists?(test)
40
+ puts " Error found for: #{test}"
41
+ raise RuntimeError.new "'#{File.basename(test)}' is not a valid file."
42
+ else
43
+ puts "#{File.basename(test)}: \t \t \t successfully validated."
44
+ end
45
+ end
46
+
47
+ puts "\nLaunching RSpec Regression Tests"
48
+ rspec_testlist = rspec_testlist.map{|r| 'tests/spec/'.concat(r)}.join(", ")
49
+
50
+ command_l = "rspec --pattern \"#{rspec_testlist}\""
51
+ puts "\n\nRSpec with: #{command_l}"
52
+
53
+ result2, err, status = Open3.capture3("#{command_l}")
54
+
55
+ #Give user feedback without going into the regression logs
56
+ reportfile = File.open(Dir.pwd + "/reports/#{logfilename}", "w")
57
+
58
+ if err.length != 0
59
+ puts "ERROR FOUND, WRITING TO '#{reportfile.path}'"
60
+ elsif result2.include? "Pending: "
61
+ puts "NO ERRORS FOUND, BUT INCOMPLETE SPEC FOUND. WRITING TO '#{reportfile.path}'"
62
+ else
63
+ puts "NO ERRORS FOUND."
64
+ end
65
+ STDOUT.puts "Finished Spec Testing"
66
+ $stdout.puts "Writing out report to log-file"
67
+
68
+ reportfile.write("#{result2}")
69
+ reportfile.write("Error: #{err}")
70
+
71
+ $stdout.puts "Test Completed"
data/lib/common.rb ADDED
@@ -0,0 +1,97 @@
1
+ module Common
2
+ require 'yaml'
3
+
4
+ if(File.exists?('config/config.yml'))
5
+ CONFIG = YAML.load_file('config/config.yml') #unless defined? CONFIG
6
+ else
7
+ puts 'WARNING: Config file not found'
8
+ end
9
+
10
+ def regression_list(filename)
11
+ filename = "#{Dir.pwd}" + "/#{filename}"
12
+ puts "searching for #{filename}\n"
13
+ if(File.exists?(filename))
14
+ result = YAML.load_file(filename) #unless defined? CONFIG
15
+ else
16
+ puts "\n\n#{filename} was not found. \nPlease check the file then try again.\n\n"
17
+ exit(1)
18
+ end
19
+ result
20
+ end
21
+
22
+ def logfilename
23
+ time_formatted = Time.now.strftime('%m_%d_%Y_%I_%M_%p') #EXAMPLE: 01_14_2016_11_13_AM
24
+ filenametime = [time_formatted,'_regression.log'].join
25
+ end
26
+
27
+ # todo: request test id from factory or test-id api/application
28
+ def test_id
29
+ return {test_id:CONFIG['testid'], password: CONFIG['password']}
30
+ end
31
+
32
+ def config
33
+ return CONFIG
34
+ end
35
+
36
+ def env
37
+ CONFIG['env']
38
+ end
39
+
40
+ def browser
41
+ CONFIG['browser']
42
+ end
43
+
44
+ def dayofweek
45
+ Date.today.strftime("%A")
46
+ end
47
+
48
+ # check RUBY_PLATFORM to determine OS. returns string (uppercase)
49
+ def os
50
+ if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
51
+ "WINDOWS"
52
+ elsif (/darwin/ =~ RUBY_PLATFORM) != nil
53
+ "MAC"
54
+ else
55
+ "LINUX"
56
+ end
57
+ end
58
+
59
+ ################################################################
60
+ # creates the test list for this particular regression run
61
+ # sources of test for tests is -r & test_list or -t options
62
+ ################################################################
63
+ def testlist_constructor (regression_test_list = nil)
64
+ constructor_rspec_testlist = Array.new
65
+
66
+ if (regression_test_list.nil?)
67
+ spec_dir_content = Dir[Dir.pwd + "/tests/spec/*_spec.rb"]
68
+ spec_dir_content.each do |test|
69
+ puts "Adding... #{File.basename(test)}..."
70
+ constructor_rspec_testlist.push("#{$test_dir_path}" + "#{File.basename(test)}" )
71
+ end
72
+ return constructor_rspec_testlist
73
+ end
74
+
75
+ # case: tests passed via command line or from a test_list
76
+ regression_test_list.each do |test|
77
+ puts "Adding... #{File.basename(test)}..."
78
+ constructor_rspec_testlist.push("#{$test_dir_path}" + "#{File.basename(test)}" )
79
+ end
80
+ return constructor_rspec_testlist
81
+ end
82
+
83
+ def run_acceptance_tests (reportfile)
84
+ STDOUT.puts "Starting Test Acceptance Tests"
85
+ result1, err, status = Open3.capture3('cucumber', 'tests/acceptance')
86
+
87
+ # Give user feedback without going into the regression logs
88
+ if err.length != 0
89
+ puts "ERROR FOUND, WRITING TO #{reportfile.path}"
90
+ else
91
+ puts "NO ERRORS FOUND."
92
+ end
93
+ STDOUT.puts "Finished Acceptance Testing"
94
+ end
95
+
96
+
97
+ end
data/lib/setup.rb ADDED
@@ -0,0 +1,69 @@
1
+ require 'tar'
2
+ include Util::Tar
3
+ module Setup
4
+
5
+ def bundle_and_tar
6
+ io = Util::Tar::tar('template')
7
+ f = File.open('compress_template', 'w+')
8
+ f.binmode
9
+ f.write io.read
10
+ f.close
11
+ end
12
+
13
+ def unbundle_and_untar(path, projectname)
14
+ f = File.open(path.concat('compress_template'), 'r')
15
+ puts "Writing #{File.expand_path(f)} To:: #{projectname}.... "
16
+ b = f.read
17
+ ba = StringIO.new(b)
18
+ Util::Tar::untar(ba,projectname)
19
+ end
20
+
21
+ def scaffold
22
+ puts "Adding Directory Structure"
23
+ Dir.mkdir("reports2")
24
+ FileUtils::mkdir_p "/tests/spec"
25
+ FileUtils::mkdir_p("#{dir_name}/reports") \
26
+ unless File.exists?('reports')
27
+ end
28
+
29
+ def cml_options
30
+ options={}
31
+ #ruby.about.com/od/advancedruby/a/optionparser.htm
32
+ optparse = OptionParser.new do |opts|
33
+
34
+ opts.banner = "Usage: runregress [options]"
35
+
36
+ opts.on("-v", "--verbose", "Run in verbose mode") do|v|
37
+ options[:verbose] = v
38
+ end
39
+ opts.on("-s", "--setup", "Setup new projet") do |s|
40
+ options[:setup] = true
41
+ scaffold
42
+ end
43
+
44
+ opts.on('-l', '--logfile FILENAME', 'Write Log to FILE') do |file|
45
+ options[:logfile] = file
46
+ puts "using file name: #{file}"
47
+ end
48
+
49
+ opts.on('-r', '--test_list FILENAME', 'File with Tests for this regression') do |file|
50
+ options[:regression_file] = file
51
+ puts "\nRunning Regression with Test_List from: #{file} \n"
52
+ end
53
+
54
+ opts.on('-t', '--test test1,test2', Array, 'tests to run') do |tests|
55
+ options[:testlist] = tests
56
+ puts "Running Tests: #{options[:testlist]}"
57
+ end
58
+
59
+ opts.on('-n', '--new PROJECTNAME','Create new project')do |projectname|
60
+ options[:projectname] = projectname
61
+ end
62
+ opts.on("-h", "--help", "Display this screen") do |h|
63
+ puts opts
64
+ exit
65
+ end
66
+ end.parse!
67
+ options
68
+ end
69
+ end
data/lib/tar.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 'rubygems'
2
+ require 'rubygems/package'
3
+ require 'zlib'
4
+ require 'fileutils'
5
+
6
+ module Util
7
+ module Tar
8
+ # Creates a tar file in memory recursively
9
+ # from the given path.
10
+ #
11
+ # Returns a StringIO whose underlying String
12
+ # is the contents of the tar file.
13
+ def tar(path)
14
+ tarfile = StringIO.new("")
15
+ Gem::Package::TarWriter.new(tarfile) do |tar|
16
+ Dir[File.join(path, "**/*")].each do |file|
17
+ mode = File.stat(file).mode
18
+ relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
19
+
20
+ if File.directory?(file)
21
+ tar.mkdir relative_file, mode
22
+ else
23
+ tar.add_file relative_file, mode do |tf|
24
+ File.open(file, "rb") { |f| tf.write f.read }
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ tarfile.rewind
31
+ tarfile
32
+ end
33
+
34
+ # gzips the underlying string in the given StringIO,
35
+ # returning a new StringIO representing the
36
+ # compressed file.
37
+ def gzip(tarfile)
38
+ gz = StringIO.new("")
39
+ z = Zlib::GzipWriter.new(gz)
40
+ z.write tarfile.string
41
+ z.close # this is necessary!
42
+
43
+ # z was closed to write the gzip footer, so
44
+ # now we need a new StringIO
45
+ StringIO.new gz.string
46
+ end
47
+
48
+ # un-gzips the given IO, returning the
49
+ # decompressed version as a StringIO
50
+ def ungzip(tarfile)
51
+ z = Zlib::GzipReader.new(tarfile)
52
+ unzipped = StringIO.new(z.read)
53
+ z.close
54
+ unzipped
55
+ end
56
+
57
+ # untars the given IO into the specified
58
+ # directory
59
+ def untar(io, destination)
60
+ Gem::Package::TarReader.new io do |tar|
61
+ tar.each do |tarfile|
62
+ destination_file = File.join destination, tarfile.full_name
63
+
64
+ if tarfile.directory?
65
+ FileUtils.mkdir_p destination_file
66
+ else
67
+ destination_directory = File.dirname(destination_file)
68
+ FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
69
+ File.open destination_file, "wb" do |f|
70
+ f.print tarfile.read
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+
80
+ ### Usage Example: ###
81
+ #
82
+ # include Util::Tar
83
+ #
84
+ # io = tar("./Desktop") # io is a TAR of files
85
+ # gz = gzip(io) # gz is a TGZ
86
+ #
87
+ # io = ungzip(gz) # io is a TAR
88
+ # untar(io, "./untarred") # files are untarred
89
+ #
90
+ # credit to:
91
+ # https://gist.github.com/sinisterchipmunk/1335041#file-tar-rb
@@ -0,0 +1,3 @@
1
+ module WatirTestframework
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "watir_testframework/version"
2
+
3
+ module WatirTestframework
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: watir_testframework
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Vladmr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: watir-webdriver
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.1
69
+ description: Test framework based on Watir, Ruby, Git and Rspec
70
+ email:
71
+ - vcharlem@gmail.com
72
+ executables:
73
+ - runregress
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - bin/compress_template
78
+ - bin/runregress
79
+ - lib/common.rb
80
+ - lib/setup.rb
81
+ - lib/tar.rb
82
+ - lib/watir_testframework.rb
83
+ - lib/watir_testframework/version.rb
84
+ homepage: https://github.com/vcharlem/watir_testframework.git
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.5
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Web Application TestFramework
108
+ test_files: []
109
+ has_rdoc: