gondola 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,85 @@
1
+ # Gondola
2
+
3
+ Gondola is a ruby gem which aims to bridge the gap between two very prominent, open source, quality assurance tools, Selenium IDE and Sauce Labs.
4
+ Many quality assurance professionals who don't have the necessary technical skills to write Selenium webdriver-based unit tests prefer to do their
5
+ web regression testing using solely the Selenium IDE and then exporting those test cases by some means to Sauce Labs' system.
6
+
7
+ Gondola offers an easier and more convenient system for dispatching tests written in Selenium IDE to a Sauce Labs account. Gondola transforms the html
8
+ that Selenium IDE produces by default and ships it to Sauce Labs across a number of browsers in parallel. Test suites and projects can be easily organized
9
+ with simple file directory structures.
10
+
11
+ Beyond the console application that comes with the gem, Gondola offers a small API for integrating Gondola's features into custom web apps. This allows
12
+ a user to bring Gondola's simplicity into an existing testing suite or a new web application. Specifically, we have a plan to write a sample Gondola web
13
+ app to demonstrate its power.
14
+
15
+ ## Installation
16
+
17
+ $ gem install gondola
18
+
19
+ NOTE: You may run into problems if rubygems' executable path is not in your `$PATH` environment variable. See rubygems' documentation
20
+ for more details.
21
+
22
+ ## Usage
23
+
24
+ Gondola offers a simplistic command line application for quickly debugging tests written in the Selenium IDE. Gondola also offers a short and sweet API for
25
+ integrating Gondola's features into any other application.
26
+
27
+ ### Getting started
28
+
29
+ $ gondola help
30
+
31
+ Will get you started with the basic commands available. The most used and main function of gondola is the `run` command.
32
+
33
+ $ gondola run [options] [tests]
34
+
35
+ The available `[options]` are:
36
+
37
+ * `-s` or `--super_parallel`: This activates "super\_parallel" mode which will not only execute all browsers in parallel but also all the
38
+ test cases. This mode is experimental and may slow down Sauce Labs considerably. Use at your own risk.
39
+ * `-r` or `--recursive`: This activates recursive search mode. When you supply Gondola with a directory containing tests, using this option will
40
+ enable sub directory searching.
41
+
42
+ The `[tests]` attribute refers to a list of test cases or test suites:
43
+
44
+ * Test cases can either be in HTML format (Selenium IDE saves) or in ruby format which is just a bunch of commands that you would like to execute.
45
+ * NOTE: The ruby test case feature is under construction and should not be used at the moment.
46
+ * Test suites are directories that contain many test cases.
47
+
48
+ ### Integrating with an existing product
49
+
50
+ require 'rubygems'
51
+ require 'gondola'
52
+
53
+ browsers = [
54
+ {:os => "Windows 2003", :browser => "firefox", :browser_version => "3.6"},
55
+ {:os => "Windows 2003", :browser => "iexplore", :browser_version => "8" },
56
+ ]
57
+
58
+ runner = Gondola::TestRunner.new
59
+ runner.add_test "example.html"
60
+ runner.run({:base_url => "http://www.google.com", :browsers => browsers})
61
+
62
+ The above code does several things:
63
+
64
+ * `runner.add_test "example.html"` adds the test case "example.html" to the list of tests that this runner will execute when you tell it to
65
+ * `runner.run(opts={})` runs all the tests that you've added with the options specified. The list of available options is long and a work in progress
66
+ with the rest of the documentation.
67
+
68
+ The end result here is that the test case that you have written with Selenium IDE, "example.html", is converted to ruby on the fly and then sent
69
+ to Sauce Labs with two browser settings in parallel.
70
+
71
+ ## Contributing to gondola
72
+
73
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
74
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
75
+ * Fork the project
76
+ * Start a feature/bugfix branch
77
+ * Commit and push until you are happy with your contribution
78
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
79
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
80
+
81
+ ## Copyright
82
+
83
+ Copyright (c) 2011 Agora Games. See LICENSE.txt for
84
+ further details.
85
+
data/bin/gondola CHANGED
@@ -45,18 +45,19 @@ class RunCommand < CmdParse::Command
45
45
  # Function that is executed when a user issues a run command
46
46
  def execute(args)
47
47
  if args.length < 1
48
- puts run.usage
48
+ puts usage
49
49
  exit 1
50
50
  end
51
- test = args[0]
52
51
  # Can either provide directory or file
53
- if File.exists?(test)
54
- runner = Gondola::TestRunner.new
55
- runner.add_test(test)
56
- runner.run(@opts)
57
- else
58
- puts "Could not find file \"#{test}\""
52
+ runner = Gondola::TestRunner.new
53
+ args.each do |t|
54
+ if File.exists? t
55
+ runner.add_test t
56
+ else
57
+ puts "Could not find \"#{t}\""
58
+ end
59
59
  end
60
+ runner.run(@opts)
60
61
  end
61
62
  end
62
63
  cmd.add_command(RunCommand.new)
data/gondola.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gondola}
8
- s.version = "1.1.6"
8
+ s.version = "1.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew Perry"]
12
- s.date = %q{2011-03-10}
12
+ s.date = %q{2011-03-16}
13
13
  s.default_executable = %q{gondola}
14
14
  s.description = %q{
15
15
  Gondola is Ruby command line utility and as well as a library which helps
@@ -21,14 +21,14 @@ Gem::Specification.new do |s|
21
21
  s.executables = ["gondola"]
22
22
  s.extra_rdoc_files = [
23
23
  "LICENSE.txt",
24
- "README.rdoc"
24
+ "README.markdown"
25
25
  ]
26
26
  s.files = [
27
27
  ".document",
28
28
  "Gemfile",
29
29
  "Gemfile.lock",
30
30
  "LICENSE.txt",
31
- "README.rdoc",
31
+ "README.markdown",
32
32
  "Rakefile",
33
33
  "bin/gondola",
34
34
  "examples/config.yml",
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  s.homepage = %q{http://github.com/perrym5/gondola}
49
49
  s.licenses = ["MIT"]
50
50
  s.require_paths = ["lib"]
51
- s.rubygems_version = %q{1.6.0}
51
+ s.rubygems_version = %q{1.6.1}
52
52
  s.summary = %q{Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services}
53
53
  s.test_files = [
54
54
  "test/helper.rb",
@@ -7,9 +7,6 @@ module Gondola
7
7
  class Tester
8
8
  attr_reader :cmd_num, :sel, :converter, :job_id
9
9
 
10
- class AssertionFailed < StandardError
11
- end
12
-
13
10
  def initialize(sel, converter)
14
11
  @sel = sel
15
12
  @converter = converter
@@ -21,9 +18,12 @@ module Gondola
21
18
  @job_id = @sel.session_id
22
19
  begin
23
20
  eval(@converter.ruby)
24
- rescue AssertionFailed
21
+ rescue => e
22
+ $stderr.puts e.message + " - stopping test."
23
+ rescue Selenium::Client::CommandError
24
+ ensure
25
+ @sel.stop()
25
26
  end
26
- @sel.stop()
27
27
  end
28
28
 
29
29
  def cmd_inc
@@ -32,25 +32,25 @@ module Gondola
32
32
 
33
33
  def assert(expr)
34
34
  unless verify(expr)
35
- raise AssertionFailed
35
+ raise "Assertion Failed"
36
36
  end
37
37
  end
38
38
 
39
39
  def assert_not(expr)
40
40
  unless verifyNot(expr)
41
- raise AssertionFailed
41
+ raise "Assertion Failed"
42
42
  end
43
43
  end
44
44
 
45
45
  def assert_eq(eq, expr)
46
46
  unless verify(eq, expr)
47
- raise AssertionFailed
47
+ raise "Assertion Failed"
48
48
  end
49
49
  end
50
50
 
51
51
  def assert_not_eq(eq, expr)
52
52
  unless verifyNot(eq, expr)
53
- raise AssertionFailed
53
+ raise "Assertion Failed"
54
54
  end
55
55
  end
56
56
 
@@ -7,77 +7,60 @@ require 'gondola'
7
7
 
8
8
  module Gondola
9
9
  class TestRunner
10
- attr_accessor :tests
10
+ attr_reader :tests
11
11
 
12
12
  def initialize
13
13
  @tests = []
14
14
  end
15
15
 
16
+ # Function to add a test to the member array of
17
+ # tests for this test run
16
18
  def add_test(file)
17
19
  @tests.push(file)
18
20
  end
19
21
 
22
+ # Function to run all tests that have been added
23
+ # - opts: hash which can be used to override the
24
+ # configuration from yml files
20
25
  def run(opts = {})
26
+ # Cannot run tests if there are none
21
27
  if @tests.empty?
22
28
  puts "No tests to run"
23
29
  end
30
+ # TODO: Need to implement a super-parallel ability( dangerous )
24
31
  if opts[:super_parallel] == true
25
32
  puts "Work in progress, please run again without the super parallel flag"
26
33
  else
34
+ # Iterate over all tests and dispatch each to Sauce Labs
27
35
  @tests.each do |test|
28
36
  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
- files.concat(Dir.glob(prepend + "*.rb"))
36
- files.each do |file|
37
- conf = configure(File.expand_path(File.dirname(file)))
38
- run_test(file, conf)
37
+ Dir.chdir(test) do
38
+ prepend = ""
39
+ if opts[:recursive] == true
40
+ prepend = "**/"
41
+ end
42
+ files = Dir.glob(prepend + "*.html")
43
+ files.concat(Dir.glob(prepend + "*.rb"))
44
+ files.each do |file|
45
+ converter,global,browsers = aggregate_data(file, opts)
46
+ run_test(converter, global, browsers)
47
+ end
39
48
  end
40
49
  else
41
- conf = configure(File.expand_path(File.dirname(test)))
42
- run_test(test, conf)
50
+ file = File.basename(test)
51
+ Dir.chdir(File.dirname(test)) do
52
+ converter,global,browsers = aggregate_data(file, opts)
53
+ run_test(converter, global, browsers)
54
+ end
43
55
  end
44
56
  end
45
57
  end
46
58
  end
47
59
 
48
60
  private
49
- # Function to configure sauce labs' gem with proper api information
50
- # as well as populate the configuration for the specific test being run
51
- def configure(file)
52
- # Load possible paths for the api information (Sauce already does this to some extent
53
- # but more paths were required for this gem)
54
- conf = {}
55
- apiPaths = [
56
- File.expand_path(File.join(file, "ondemand.yml")),
57
- File.expand_path(File.join(file, "../ondemand.yml")),
58
- ]
59
- apiPaths.each do |path|
60
- if File.exists?(path)
61
- conf = YAML.load_file(path)
62
- break
63
- end
64
- end
65
-
66
- # Load possible paths for the configuration information
67
- configPaths = [
68
- File.expand_path(File.join(file, "../config.yml")),
69
- File.expand_path(File.join(file, "config.yml")),
70
- ]
71
- configPaths.each do |path|
72
- if File.exists?(path)
73
- conf.merge! YAML.load_file(path)
74
- end
75
- end
76
- return conf
77
- end
78
-
79
- # Function to run and parallelize the given test on the given browsers
80
- def run_test(file, conf)
61
+ # Function to collect configuration data from various
62
+ # sources so that the test can run properly
63
+ def aggregate_data(file, opts)
81
64
  # Initialize a converter object based on filetype
82
65
  converter = nil
83
66
  if File.extname(file) == '.html'
@@ -85,6 +68,10 @@ module Gondola
85
68
  elsif File.extname(file) == '.rb'
86
69
  converter = Gondola::LegacyConverter.new(file)
87
70
  end
71
+ # Load file config data
72
+ conf = config_from_file(file)
73
+ # Merge in user-supplied data
74
+ conf.merge! opts
88
75
  # Set global information
89
76
  global = {}
90
77
  global[:job_name] = converter.name
@@ -93,18 +80,57 @@ module Gondola
93
80
  end
94
81
  global.merge! conf.reject { |k,v| !([:username, :access_key].include?(k)) }
95
82
  global[:browser_url] = conf[:base_url]
83
+
84
+ return [converter, global, conf[:browsers]]
85
+ end
86
+
87
+ # Function to read any config files which contain data for this
88
+ # test case or suite
89
+ def config_from_file(file, api=true, data=true)
90
+ # If the given test is just a file then start your search in
91
+ # its parent directory
92
+ unless File.directory? file
93
+ return config_from_file(File.dirname(file))
94
+ end
95
+ # Load any config files in the current directory only if
96
+ # a config hasn't already been found
97
+ conf = {}
98
+ Dir.chdir(file) do
99
+ if api
100
+ if File.exists? "ondemand.yml"
101
+ conf.merge! YAML.load_file("ondemand.yml")
102
+ api = false
103
+ end
104
+ end
105
+ if data
106
+ if File.exists? "config.yml"
107
+ conf.merge! YAML.load_file("config.yml")
108
+ data = false
109
+ end
110
+ end
111
+ end
112
+ # Recurse through the parent directories and merge the
113
+ # current configuration
114
+ unless file == File.dirname(file)
115
+ return config_from_file(File.dirname(file), api, data).merge(conf)
116
+ end
117
+ return conf
118
+ end
119
+
120
+ # Function to run and parallelize the given test on the given browsers
121
+ def run_test(converter, global, browsers)
96
122
  # 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
123
+ Parallel.map(browsers, :in_threads => browsers.size) do |request|
124
+ # Add global information to this request
125
+ request.merge! global
100
126
  # Request a new selenium object from Sauce
101
- selenium = Sauce::Selenium.new(browser)
127
+ selenium = Sauce::Selenium.new(request)
102
128
  # Begin test using a tester object
103
129
  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}"
130
+ browser_string = "#{request[:os]} #{request[:browser]} #{request[:browser_version]}"
131
+ puts "Starting test case \"#{converter.name}\" with: #{browser_string}"
106
132
  tester.begin
107
- puts "#{file} finished - Sauce Job ID: #{tester.job_id}"
133
+ puts "#{converter.name} finished - Sauce Job ID: #{tester.job_id}"
108
134
  end
109
135
  puts
110
136
  end
@@ -1,3 +1,3 @@
1
1
  module Gondola
2
- VERSION = "1.1.6"
2
+ VERSION = "1.1.7"
3
3
  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.6
5
+ version: 1.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Perry
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-10 00:00:00 -05:00
13
+ date: 2011-03-16 00:00:00 -04:00
14
14
  default_executable: gondola
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -76,13 +76,13 @@ extensions: []
76
76
 
77
77
  extra_rdoc_files:
78
78
  - LICENSE.txt
79
- - README.rdoc
79
+ - README.markdown
80
80
  files:
81
81
  - .document
82
82
  - Gemfile
83
83
  - Gemfile.lock
84
84
  - LICENSE.txt
85
- - README.rdoc
85
+ - README.markdown
86
86
  - Rakefile
87
87
  - bin/gondola
88
88
  - examples/config.yml
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- hash: 351993709
115
+ hash: 1003150642294150752
116
116
  segments:
117
117
  - 0
118
118
  version: "0"
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements: []
126
126
 
127
127
  rubyforge_project:
128
- rubygems_version: 1.6.0
128
+ rubygems_version: 1.6.1
129
129
  signing_key:
130
130
  specification_version: 3
131
131
  summary: Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = gondola
2
-
3
- WORK IN PROGRESS
4
-
5
- == Contributing to gondola
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 Agora Games. See LICENSE.txt for
18
- further details.
19
-