gondola 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +62 -0
- data/bin/gondola +46 -49
- data/gondola.gemspec +80 -0
- data/lib/gondola.rb +1 -0
- data/lib/gondola/converter.rb +196 -199
- data/lib/gondola/tester.rb +71 -74
- data/lib/gondola/testrunner.rb +93 -98
- data/lib/gondola/version.rb +9 -0
- data/test/helper.rb +18 -0
- data/test/test_gondola.rb +7 -0
- metadata +62 -17
- data/LICENSE +0 -19
- data/README.markdown +0 -0
data/lib/gondola/tester.rb
CHANGED
@@ -1,92 +1,89 @@
|
|
1
|
-
# Gondola
|
2
|
-
# FILE: tester.rb
|
3
|
-
# AUTHOR: Matthew Perry
|
4
|
-
# DESCRIPTION:
|
1
|
+
# Gondola - tester.rb:
|
5
2
|
# Module which contains all the necessary functions
|
6
3
|
# for asserting and verifying various functions without
|
7
4
|
# the need for a unit testing framework
|
8
5
|
|
9
6
|
module Gondola
|
10
|
-
|
11
|
-
|
7
|
+
class Tester
|
8
|
+
attr_reader :cmd_num, :sel, :converter, :job_id
|
12
9
|
|
13
|
-
|
14
|
-
|
10
|
+
class AssertionFailed < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(sel, converter)
|
14
|
+
@sel = sel
|
15
|
+
@converter = converter
|
16
|
+
@cmd_num = 1
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def begin
|
20
|
+
@sel.start()
|
21
|
+
@job_id = @sel.session_id
|
22
|
+
begin
|
23
|
+
eval(@converter.ruby)
|
24
|
+
rescue AssertionFailed
|
25
|
+
end
|
26
|
+
@sel.stop()
|
27
|
+
end
|
21
28
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
begin
|
26
|
-
eval( @converter.ruby )
|
27
|
-
rescue AssertionFailed
|
28
|
-
end
|
29
|
-
@sel.stop()
|
30
|
-
end
|
29
|
+
def cmd_inc
|
30
|
+
@cmd_num+=1
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def assert(expr)
|
34
|
+
unless verify(expr)
|
35
|
+
raise AssertionFailed
|
36
|
+
end
|
37
|
+
end
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def assert_not(expr)
|
40
|
+
unless verifyNot(expr)
|
41
|
+
raise AssertionFailed
|
42
|
+
end
|
43
|
+
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def assertEq( eq, expr )
|
49
|
-
unless verify( eq, expr )
|
50
|
-
raise AssertionFailed
|
51
|
-
end
|
52
|
-
end
|
45
|
+
def assert_eq(eq, expr)
|
46
|
+
unless verify(eq, expr)
|
47
|
+
raise AssertionFailed
|
48
|
+
end
|
49
|
+
end
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
def assert_not_eq(eq, expr)
|
52
|
+
unless verifyNot(eq, expr)
|
53
|
+
raise AssertionFailed
|
54
|
+
end
|
55
|
+
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
def verify(expr)
|
58
|
+
unless expr
|
59
|
+
$stderr.puts "Command #{@cmd_num} returned false, expecting true"
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
return true
|
63
|
+
end
|
67
64
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
def verify_not(expr)
|
66
|
+
if expr
|
67
|
+
$stderr.puts "Command #{@cmd_num} returned true, expecting false"
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
return true
|
71
|
+
end
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
73
|
+
def verify_eq(eq, expr)
|
74
|
+
unless eq == expr
|
75
|
+
@stderr.puts "Command #{@cmd_num} returned '#{expr}', expecting '#{eq}'"
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
return true
|
79
|
+
end
|
83
80
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
81
|
+
def verify_not_eq(eq, expr)
|
82
|
+
if eq == expr
|
83
|
+
@stderr.puts "Command #{@cmd_num} returned '#{expr}', expecting '#{eq}'"
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
return true
|
91
87
|
end
|
88
|
+
end
|
92
89
|
end
|
data/lib/gondola/testrunner.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
# Gondola v2
|
2
|
-
# FILE: testrunner.rb
|
3
|
-
# AUTHOR: Matthew Perry
|
4
|
-
# DESCRIPTION:
|
1
|
+
# Gondola v2 - testrunner.rb:
|
5
2
|
# A wrapper for all the tasks required for launching a run
|
6
3
|
# of a test suite or test case on several browsers
|
7
4
|
|
@@ -9,109 +6,107 @@ require 'rubygems'
|
|
9
6
|
require 'gondola'
|
10
7
|
|
11
8
|
module Gondola
|
12
|
-
|
13
|
-
|
9
|
+
class TestRunner
|
10
|
+
attr_accessor :tests
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def initialize
|
13
|
+
@tests = []
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def add_test(file)
|
17
|
+
@tests.push(file)
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
def run(opts = {})
|
21
|
+
if @tests.empty?
|
22
|
+
puts "No tests to run"
|
23
|
+
end
|
24
|
+
if opts[:super_parallel] == true
|
25
|
+
puts "Work in progress, please run again without the super parallel flag"
|
26
|
+
else
|
27
|
+
@tests.each do |test|
|
28
|
+
if File.directory? test
|
29
|
+
Dir.chdir(test)
|
30
|
+
prepend = ""
|
31
|
+
if opts[:recursive] == true
|
32
|
+
prepend = "**/"
|
33
|
+
end
|
34
|
+
files = Dir.glob(prepend + "*.html")
|
35
|
+
if opts[:legacy] == true
|
36
|
+
files.concat(Dir.glob(prepend + "*.rb"))
|
26
37
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@tests.each do |test|
|
31
|
-
if File.directory? test
|
32
|
-
Dir.chdir( test )
|
33
|
-
prepend = ""
|
34
|
-
if opts[:recursive] == true
|
35
|
-
prepend = "**/"
|
36
|
-
end
|
37
|
-
files = Dir.glob( prepend + "*.html" )
|
38
|
-
if opts[:legacy] == true
|
39
|
-
files.concat( Dir.glob( prepend + "*.rb" ) )
|
40
|
-
end
|
41
|
-
files.each do |file|
|
42
|
-
conf = configure( File.expand_path( File.dirname( file ) ) )
|
43
|
-
runTest( file, conf )
|
44
|
-
end
|
45
|
-
else
|
46
|
-
conf = configure( File.expand_path( File.dirname( test ) ) )
|
47
|
-
runTest( file, conf )
|
48
|
-
end
|
49
|
-
end
|
38
|
+
files.each do |file|
|
39
|
+
conf = configure(File.expand_path(File.dirname(file)))
|
40
|
+
run_test(file, conf)
|
50
41
|
end
|
42
|
+
else
|
43
|
+
conf = configure(File.expand_path(File.dirname(test)))
|
44
|
+
run_test(file, conf)
|
45
|
+
end
|
51
46
|
end
|
47
|
+
end
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# Load possible paths for the configuration information
|
72
|
-
configPaths = [
|
73
|
-
File.expand_path( File.join( file, "../config.yml" ) ),
|
74
|
-
File.expand_path( File.join( file, "config.yml" ) ),
|
75
|
-
]
|
76
|
-
configPaths.each do |path|
|
77
|
-
if File.exists?( path )
|
78
|
-
conf.merge! YAML.load_file( path )
|
79
|
-
end
|
80
|
-
end
|
81
|
-
conf = conf.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
82
|
-
conf[:browsers].map! do |browser|
|
83
|
-
browser.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
84
|
-
end
|
85
|
-
return conf
|
50
|
+
private
|
51
|
+
# Function to configure sauce labs' gem with proper api information
|
52
|
+
# as well as populate the configuration for the specific test being run
|
53
|
+
def configure(file)
|
54
|
+
# Load possible paths for the api information (Sauce already does this to some extent
|
55
|
+
# but more paths were required for this gem)
|
56
|
+
conf = {}
|
57
|
+
apiPaths = [
|
58
|
+
File.expand_path(File.join(file, "ondemand.yml")),
|
59
|
+
File.expand_path(File.join(file, "../ondemand.yml")),
|
60
|
+
]
|
61
|
+
apiPaths.each do |path|
|
62
|
+
if File.exists?(path)
|
63
|
+
conf = YAML.load_file(path)
|
64
|
+
break
|
86
65
|
end
|
66
|
+
end
|
87
67
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
global[:job_name] = "#{conf[:project_name]} - #{global[:job_name]}"
|
97
|
-
end
|
98
|
-
global[:browser_url] = conf[:base_url]
|
99
|
-
# Spawn n threads
|
100
|
-
Parallel.map( conf[:browsers], :in_threads => conf[:browsers].size ) do |browser|
|
101
|
-
# Convert to symbols
|
102
|
-
browser = browser.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
103
|
-
# Add global information to this configuration
|
104
|
-
browser.merge! global
|
105
|
-
# Request a new selenium object from Sauce
|
106
|
-
selenium = Sauce::Selenium.new( browser )
|
107
|
-
# Begin test using a tester object
|
108
|
-
tester = Gondola::Tester.new( selenium, converter )
|
109
|
-
browser_string = "#{browser[:os]} #{browser[:browser]} #{browser[:browser_version]}"
|
110
|
-
puts "Starting test case \"#{file}\" with: #{browser_string}"
|
111
|
-
tester.begin
|
112
|
-
puts "#{file} finished - Sauce Job ID: #{tester.job_id}"
|
113
|
-
end
|
114
|
-
puts
|
68
|
+
# Load possible paths for the configuration information
|
69
|
+
configPaths = [
|
70
|
+
File.expand_path(File.join(file, "../config.yml")),
|
71
|
+
File.expand_path(File.join(file, "config.yml")),
|
72
|
+
]
|
73
|
+
configPaths.each do |path|
|
74
|
+
if File.exists?(path)
|
75
|
+
conf.merge! YAML.load_file(path)
|
115
76
|
end
|
77
|
+
end
|
78
|
+
conf = conf.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
79
|
+
conf[:browsers].map! do |browser|
|
80
|
+
browser.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
81
|
+
end
|
82
|
+
return conf
|
83
|
+
end
|
84
|
+
|
85
|
+
# Function to run and parallelize the given test on the given browsers
|
86
|
+
def run_test(file, conf)
|
87
|
+
# Initialize a converter object
|
88
|
+
converter = Gondola::Converter.new(file)
|
89
|
+
# Set global information
|
90
|
+
global = {}
|
91
|
+
global[:job_name] = converter.name
|
92
|
+
if conf[:project_name]
|
93
|
+
global[:job_name] = "#{conf[:project_name]} - #{global[:job_name]}"
|
94
|
+
end
|
95
|
+
global[:browser_url] = conf[:base_url]
|
96
|
+
# Spawn n threads
|
97
|
+
Parallel.map(conf[:browsers], :in_threads => conf[:browsers].size)do |browser|
|
98
|
+
# Add global information to this configuration
|
99
|
+
browser.merge! global
|
100
|
+
# Request a new selenium object from Sauce
|
101
|
+
selenium = Sauce::Selenium.new(browser)
|
102
|
+
# Begin test using a tester object
|
103
|
+
tester = Gondola::Tester.new(selenium, converter)
|
104
|
+
browser_string = "#{browser[:os]} #{browser[:browser]} #{browser[:browser_version]}"
|
105
|
+
puts "Starting test case \"#{file}\" with: #{browser_string}"
|
106
|
+
tester.begin
|
107
|
+
puts "#{file} finished - Sauce Job ID: #{tester.job_id}"
|
108
|
+
end
|
109
|
+
puts
|
116
110
|
end
|
111
|
+
end
|
117
112
|
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'gondola'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gondola
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.1.
|
5
|
+
version: 1.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Perry
|
@@ -10,12 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-03-09 00:00:00 -05:00
|
14
|
+
default_executable: gondola
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sauce
|
18
|
-
prerelease: false
|
19
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
19
|
none: false
|
21
20
|
requirements:
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
- !ruby/object:Gem::Version
|
24
23
|
version: 0.17.5
|
25
24
|
type: :runtime
|
25
|
+
prerelease: false
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: parallel
|
29
|
-
prerelease: false
|
30
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
30
|
none: false
|
32
31
|
requirements:
|
@@ -34,31 +33,73 @@ dependencies:
|
|
34
33
|
- !ruby/object:Gem::Version
|
35
34
|
version: 0.5.2
|
36
35
|
type: :runtime
|
36
|
+
prerelease: false
|
37
37
|
version_requirements: *id002
|
38
|
-
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: shoulda
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.0.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: jeweler
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.5.2
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
description: "\n Gondola is Ruby command line utility and as well as a library which helps\n for integrate the Selenium IDE more tightly with Sauce Labs' Ondemand services and\n provide greater ease for those who would like to use both tools but do not have\n enough technical knowledge\n "
|
39
72
|
email: mperry@agoragames.com
|
40
73
|
executables:
|
41
74
|
- gondola
|
42
75
|
extensions: []
|
43
76
|
|
44
|
-
extra_rdoc_files:
|
45
|
-
|
77
|
+
extra_rdoc_files:
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.rdoc
|
46
80
|
files:
|
47
|
-
-
|
48
|
-
-
|
81
|
+
- .document
|
82
|
+
- Gemfile
|
83
|
+
- Gemfile.lock
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.rdoc
|
49
86
|
- Rakefile
|
50
87
|
- bin/gondola
|
51
88
|
- examples/config.yml
|
52
89
|
- examples/gondola_agora_fail.html
|
53
90
|
- examples/gondola_agora_pass.html
|
91
|
+
- gondola.gemspec
|
92
|
+
- lib/gondola.rb
|
54
93
|
- lib/gondola/converter.rb
|
55
94
|
- lib/gondola/tester.rb
|
56
95
|
- lib/gondola/testrunner.rb
|
57
|
-
- lib/gondola.rb
|
96
|
+
- lib/gondola/version.rb
|
97
|
+
- test/helper.rb
|
98
|
+
- test/test_gondola.rb
|
58
99
|
has_rdoc: true
|
59
|
-
homepage:
|
60
|
-
licenses:
|
61
|
-
|
100
|
+
homepage: http://github.com/perrym5/gondola
|
101
|
+
licenses:
|
102
|
+
- MIT
|
62
103
|
post_install_message:
|
63
104
|
rdoc_options: []
|
64
105
|
|
@@ -69,6 +110,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
110
|
requirements:
|
70
111
|
- - ">="
|
71
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: -875425795
|
114
|
+
segments:
|
115
|
+
- 0
|
72
116
|
version: "0"
|
73
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
118
|
none: false
|
@@ -79,9 +123,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
123
|
requirements: []
|
80
124
|
|
81
125
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.6.
|
126
|
+
rubygems_version: 1.6.0
|
83
127
|
signing_key:
|
84
128
|
specification_version: 3
|
85
129
|
summary: Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services
|
86
|
-
test_files:
|
87
|
-
|
130
|
+
test_files:
|
131
|
+
- test/helper.rb
|
132
|
+
- test/test_gondola.rb
|