celerity 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/History.txt +36 -0
  2. data/Manifest.txt +82 -0
  3. data/README.rdoc +78 -0
  4. data/Rakefile +25 -10
  5. data/celerity.gemspec +40 -0
  6. data/lib/celerity.rb +36 -20
  7. data/lib/celerity/browser.rb +396 -189
  8. data/lib/celerity/clickable_element.rb +25 -5
  9. data/lib/celerity/collections.rb +2 -2
  10. data/lib/celerity/container.rb +74 -61
  11. data/lib/celerity/default_viewer.rb +8 -4
  12. data/lib/celerity/disabled_element.rb +5 -5
  13. data/lib/celerity/element.rb +57 -35
  14. data/lib/celerity/element_collection.rb +22 -21
  15. data/lib/celerity/element_locator.rb +25 -18
  16. data/lib/celerity/elements/button.rb +13 -11
  17. data/lib/celerity/elements/file_field.rb +8 -4
  18. data/lib/celerity/elements/form.rb +7 -5
  19. data/lib/celerity/elements/frame.rb +6 -4
  20. data/lib/celerity/elements/image.rb +4 -4
  21. data/lib/celerity/elements/label.rb +1 -1
  22. data/lib/celerity/elements/link.rb +5 -5
  23. data/lib/celerity/elements/meta.rb +2 -1
  24. data/lib/celerity/elements/non_control_elements.rb +3 -3
  25. data/lib/celerity/elements/option.rb +7 -7
  26. data/lib/celerity/elements/radio_check.rb +18 -18
  27. data/lib/celerity/elements/select_list.rb +55 -25
  28. data/lib/celerity/elements/table.rb +21 -18
  29. data/lib/celerity/elements/table_cell.rb +1 -1
  30. data/lib/celerity/elements/table_elements.rb +1 -1
  31. data/lib/celerity/elements/table_row.rb +5 -5
  32. data/lib/celerity/elements/text_field.rb +33 -28
  33. data/lib/celerity/exception.rb +11 -5
  34. data/lib/celerity/htmlunit.rb +24 -8
  35. data/lib/celerity/htmlunit/commons-codec-1.4.jar +0 -0
  36. data/lib/celerity/htmlunit/htmlunit-2.6.jar +0 -0
  37. data/lib/celerity/htmlunit/htmlunit-core-js-2.6.jar +0 -0
  38. data/lib/celerity/htmlunit/nekohtml-1.9.13.jar +0 -0
  39. data/lib/celerity/htmlunit/{xercesImpl-2.8.1.jar → xercesImpl-2.9.1.jar} +0 -0
  40. data/lib/celerity/ignoring_web_connection.rb +15 -0
  41. data/lib/celerity/input_element.rb +1 -1
  42. data/lib/celerity/listener.rb +23 -17
  43. data/lib/celerity/short_inspect.rb +20 -0
  44. data/lib/celerity/util.rb +5 -2
  45. data/lib/celerity/version.rb +3 -10
  46. data/lib/celerity/viewer_connection.rb +89 -0
  47. data/lib/celerity/watir_compatibility.rb +2 -5
  48. data/lib/celerity/xpath_support.rb +48 -0
  49. data/spec/browser_authentication_spec.rb +16 -0
  50. data/spec/browser_spec.rb +300 -0
  51. data/spec/clickable_element_spec.rb +39 -0
  52. data/spec/default_viewer_spec.rb +23 -0
  53. data/spec/element_spec.rb +51 -0
  54. data/spec/filefield_spec.rb +18 -0
  55. data/spec/htmlunit_spec.rb +56 -0
  56. data/spec/index_offset_spec.rb +24 -0
  57. data/spec/listener_spec.rb +142 -0
  58. data/spec/spec_helper.rb +8 -0
  59. data/tasks/benchmark.rake +4 -0
  60. data/tasks/deployment.rake +43 -0
  61. data/tasks/environment.rake +7 -0
  62. data/tasks/fix.rake +25 -0
  63. data/tasks/jar.rake +4 -6
  64. data/tasks/rspec.rake +43 -0
  65. data/tasks/simple_ci.rake +94 -0
  66. data/tasks/snapshot.rake +22 -0
  67. data/tasks/website.rake +17 -0
  68. data/tasks/yard.rake +9 -0
  69. metadata +59 -26
  70. data/README.txt +0 -69
  71. data/lib/celerity/extra/method_generator.rb +0 -170
  72. data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
  73. data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
  74. data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
  75. data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
data/tasks/jar.rake CHANGED
@@ -1,11 +1,9 @@
1
- require 'celerity/version'
2
-
3
1
  namespace :jar do
4
2
  target_dir = "classes"
5
3
 
6
- desc "Compile and create celerity-complete-#{Celerity::VERSION::STRING}.jar (includes HtmlUnit)"
4
+ desc "Compile and create celerity-complete-#{Celerity::VERSION}.jar (includes HtmlUnit)"
7
5
  task :fat do
8
- file_name = "pkg/celerity-complete-#{Celerity::VERSION::STRING}.jar"
6
+ file_name = "pkg/celerity-complete-#{Celerity::VERSION}.jar"
9
7
 
10
8
  ruby_files = Dir['lib/**/*.rb']
11
9
  jar_files = Dir['lib/**/*.jar']
@@ -34,9 +32,9 @@ namespace :jar do
34
32
  sh "jar", "cvf", file_name, '-C', target_dir, '.'
35
33
  end
36
34
 
37
- desc "Compile and create celerity-#{Celerity::VERSION::STRING}.jar"
35
+ desc "Compile and create celerity-#{Celerity::VERSION}.jar"
38
36
  task :tiny do
39
- file_name = "pkg/celerity-#{Celerity::VERSION::STRING}.jar"
37
+ file_name = "pkg/celerity-#{Celerity::VERSION}.jar"
40
38
 
41
39
  ruby_files = Dir['lib/**/*.rb']
42
40
  resources = Dir['lib/celerity/resources/*']
data/tasks/rspec.rake ADDED
@@ -0,0 +1,43 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+
8
+ begin
9
+ require 'spec/rake/spectask'
10
+ rescue LoadError
11
+ puts <<-EOS
12
+ To use rspec for testing you must install rspec gem:
13
+ gem install rspec
14
+ EOS
15
+ exit(0)
16
+ end
17
+
18
+
19
+ if File.exist?(path = "spec/watirspec/watirspec.rake")
20
+ load path
21
+ end
22
+
23
+ namespace :watirspec do
24
+ desc 'Initialize and fetch the watirspec submodule'
25
+ task :init do
26
+ sh "git submodule init"
27
+ sh "git submodule update"
28
+ end
29
+ end
30
+
31
+ desc "Run the specs under spec/"
32
+ Spec::Rake::SpecTask.new do |t|
33
+ t.spec_files = FileList['spec/**/*_spec.rb']
34
+ # t.ruby_opts = %w[--headless] if RUBY_PLATFORM =~ /java/
35
+
36
+ begin
37
+ require 'rcov'
38
+ t.rcov = true
39
+ t.rcov_opts = ['--exclude', 'spec,fcntl,path_helper,yaml', '--no-rcovrt']
40
+ rescue LoadError
41
+ end
42
+
43
+ end
@@ -0,0 +1,94 @@
1
+ require "rubygems"
2
+ require "fileutils"
3
+ require "erb"
4
+ require "pp"
5
+
6
+ begin
7
+ require "mongrel"
8
+ rescue LoadError
9
+ end
10
+
11
+ task :simple_ci do
12
+ INTERVAL = (60*5)
13
+ CI_ROOT = File.dirname(__FILE__) + "/../simple_ci"
14
+ ROOT = File.expand_path(CI_ROOT + "/..")
15
+ Dir.mkdir(CI_ROOT) unless File.exist?(CI_ROOT)
16
+
17
+ class SpecFile < Struct.new(:file, :describes)
18
+ attr_accessor :passed
19
+ end
20
+
21
+ def get_specs
22
+ Dir[File.dirname(__FILE__) + '/../spec/**/*_spec.rb'].map do |file|
23
+ SpecFile.new(file, File.read(file)[/describe\(?\s*["'](.+?)["']/, 1] || File.basename(file) )
24
+ end
25
+ end
26
+
27
+ class SimpleCI < Mongrel::HttpHandler
28
+ def self.template=(rhtml); @@template = rhtml; end
29
+
30
+ def initialize(results)
31
+ @results = results
32
+ super()
33
+ end
34
+
35
+ def process(request, response)
36
+ response.start(200) do |header, io|
37
+ if @results
38
+ io.write ERB.new(@@template).result
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ @results = {}
46
+ SimpleCI.template = <<-HTML
47
+ <html>
48
+ <head>
49
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
50
+ <title>Celerity Simple CI</title>
51
+ <style type="text/css" media="screen">
52
+ body {font: 10px/16px "Lucida Grande", Geneva, Arial, Verdana, sans-serif; background-color: #fff;color: #333;}
53
+ a{color:#2971a7;}
54
+ a:link,a:visited,a:active{text-decoration:none}
55
+ a:hover{text-decoration:underline}
56
+ table{border-collapse:collapse;border-spacing:0;margin-left:24px;}
57
+ </style>
58
+ </head>
59
+
60
+ <h1> Celerity </h1>
61
+ <h3><a href="result/">Test Results</a></h3>
62
+ <h3><a href="coverage/">Code Coverage</a></h3>
63
+ </html>
64
+ HTML
65
+
66
+ begin
67
+ @server = Mongrel::HttpServer.new('0.0.0.0', '8080')
68
+ rescue NameError
69
+ abort("Run `(jruby -S) gem install mongrel` to use this task.")
70
+ end
71
+ @server.register("/result", Mongrel::DirHandler.new(CI_ROOT))
72
+ @server.register("/coverage", Mongrel::DirHandler.new(CI_ROOT + "/coverage/coverage"))
73
+ @server.register("/", SimpleCI.new(@results))
74
+ Thread.new { @server.run.join }
75
+ puts "simple_ci started on #{@server.host}:#{@server.port}"
76
+ loop do
77
+ puts %x{svn up}
78
+ puts "*** running specs at #{Time.now}"
79
+ specs = get_specs
80
+
81
+ pp specs if $DEBUG
82
+ puts "*** running rcov at #{Time.now}"
83
+ puts %x{jruby -S rake --trace --silent spec > #{CI_ROOT}/index2.html}
84
+ FileUtils.mv(CI_ROOT + "/index2.html", CI_ROOT + "/index.html", :verbose => true)
85
+ Dir[CI_ROOT + "/coverage/*"].each { |f| FileUtils.rm_r(f, :verbose => true) }
86
+ FileUtils.mv(CI_ROOT + "/../coverage", CI_ROOT + "/coverage", :verbose => true)
87
+ puts "\n*** sleeping #{Time.now}"
88
+ sleep(INTERVAL)
89
+ end
90
+
91
+ end
92
+
93
+
94
+
@@ -0,0 +1,22 @@
1
+ desc 'Download and unpack the latest HtmlUnit assembly'
2
+ task :snapshot do
3
+ files = %w[ http://build.canoo.com/htmlunit/artifacts/htmlunit-2.6-SNAPSHOT-with-dependencies.zip ]
4
+
5
+ files.each do |url|
6
+ basename = File.basename(url)
7
+ shortname = basename[/(.+?)\.zip/, 1].sub("-with-dependencies", '')
8
+ sh "curl -O #{url}"
9
+ sh "rm -rf lib/celerity/htmlunit/*.jar"
10
+ sh "unzip -tq #{basename}"
11
+ sh %Q{unzip -C #{basename} "#{shortname}/lib/*.jar" -d lib/celerity/htmlunit }
12
+
13
+ puts "Fixing paths..."
14
+ sh "cp -R lib/celerity/htmlunit/#{shortname}/lib/*.jar lib/celerity/htmlunit/"
15
+
16
+ puts "Cleaning..."
17
+ rm_r "lib/celerity/htmlunit/#{shortname}/"
18
+ rm basename
19
+
20
+ puts "...done!"
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ #desc 'Generate website files'
2
+ #task :website_generate => :ruby_env do
3
+ # (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ # sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ # end
6
+ #end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -rlgoDCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ #desc 'Generate and upload website files'
17
+ #task :website => [:website_generate, :website_upload, :publish_docs]
data/tasks/yard.rake ADDED
@@ -0,0 +1,9 @@
1
+ begin
2
+ require "yard"
3
+
4
+ YARD::Rake::YardocTask.new do |t|
5
+ t.files = ["lib/**/*.rb"]
6
+ t.options += ["-o", "website/yard"]
7
+ end
8
+ rescue LoadError
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -11,9 +11,19 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-03-19 00:00:00 +01:00
14
+ date: 2009-09-04 00:00:00 +02:00
15
15
  default_executable:
16
16
  dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: sinatra
19
+ type: :development
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.9.4
26
+ version:
17
27
  - !ruby/object:Gem::Dependency
18
28
  name: hoe
19
29
  type: :development
@@ -22,10 +32,14 @@ dependencies:
22
32
  requirements:
23
33
  - - ">="
24
34
  - !ruby/object:Gem::Version
25
- version: 1.10.0
35
+ version: 2.3.3
26
36
  version:
27
- description: "Celerity is a JRuby wrapper around HtmlUnit \xE2\x80\x93 a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir."
28
- email: jari.bakken@finn.no
37
+ description: "Celerity is a JRuby library for easy and fast functional test automation for web applications.\n\n\
38
+ It is a JRuby wrapper around HtmlUnit \xE2\x80\x93 a headless Java browser with \n\
39
+ JavaScript support. It provides a simple API for programmatic navigation through\n\
40
+ web applications. Celerity aims at being API compatible with Watir."
41
+ email:
42
+ - jari.bakken@finn.no
29
43
  executables: []
30
44
 
31
45
  extensions: []
@@ -33,11 +47,14 @@ extensions: []
33
47
  extra_rdoc_files:
34
48
  - History.txt
35
49
  - License.txt
36
- - README.txt
50
+ - Manifest.txt
37
51
  files:
38
52
  - History.txt
39
- - lib
40
- - lib/celerity
53
+ - License.txt
54
+ - Manifest.txt
55
+ - README.rdoc
56
+ - Rakefile
57
+ - celerity.gemspec
41
58
  - lib/celerity.rb
42
59
  - lib/celerity/browser.rb
43
60
  - lib/celerity/clickable_element.rb
@@ -48,7 +65,6 @@ files:
48
65
  - lib/celerity/element.rb
49
66
  - lib/celerity/element_collection.rb
50
67
  - lib/celerity/element_locator.rb
51
- - lib/celerity/elements
52
68
  - lib/celerity/elements/button.rb
53
69
  - lib/celerity/elements/file_field.rb
54
70
  - lib/celerity/elements/form.rb
@@ -67,45 +83,62 @@ files:
67
83
  - lib/celerity/elements/table_row.rb
68
84
  - lib/celerity/elements/text_field.rb
69
85
  - lib/celerity/exception.rb
70
- - lib/celerity/extra
71
- - lib/celerity/extra/method_generator.rb
72
- - lib/celerity/htmlunit
73
86
  - lib/celerity/htmlunit.rb
74
- - lib/celerity/htmlunit/commons-codec-1.3.jar
87
+ - lib/celerity/htmlunit/commons-codec-1.4.jar
75
88
  - lib/celerity/htmlunit/commons-collections-3.2.1.jar
76
89
  - lib/celerity/htmlunit/commons-httpclient-3.1.jar
77
90
  - lib/celerity/htmlunit/commons-io-1.4.jar
78
91
  - lib/celerity/htmlunit/commons-lang-2.4.jar
79
92
  - lib/celerity/htmlunit/commons-logging-1.1.1.jar
80
93
  - lib/celerity/htmlunit/cssparser-0.9.5.jar
81
- - lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar
82
- - lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar
83
- - lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar
94
+ - lib/celerity/htmlunit/htmlunit-2.6.jar
95
+ - lib/celerity/htmlunit/htmlunit-core-js-2.6.jar
96
+ - lib/celerity/htmlunit/nekohtml-1.9.13.jar
84
97
  - lib/celerity/htmlunit/sac-1.3.jar
85
98
  - lib/celerity/htmlunit/serializer-2.7.1.jar
86
99
  - lib/celerity/htmlunit/xalan-2.7.1.jar
87
- - lib/celerity/htmlunit/xercesImpl-2.8.1.jar
100
+ - lib/celerity/htmlunit/xercesImpl-2.9.1.jar
88
101
  - lib/celerity/htmlunit/xml-apis-1.3.04.jar
89
102
  - lib/celerity/identifier.rb
103
+ - lib/celerity/ignoring_web_connection.rb
90
104
  - lib/celerity/input_element.rb
91
105
  - lib/celerity/listener.rb
92
- - lib/celerity/resources
93
106
  - lib/celerity/resources/no_viewer.png
107
+ - lib/celerity/short_inspect.rb
94
108
  - lib/celerity/util.rb
95
109
  - lib/celerity/version.rb
110
+ - lib/celerity/viewer_connection.rb
96
111
  - lib/celerity/watir_compatibility.rb
97
- - License.txt
98
- - Rakefile
99
- - README.txt
100
- - tasks
112
+ - lib/celerity/xpath_support.rb
113
+ - spec/browser_authentication_spec.rb
114
+ - spec/browser_spec.rb
115
+ - spec/clickable_element_spec.rb
116
+ - spec/default_viewer_spec.rb
117
+ - spec/element_spec.rb
118
+ - spec/filefield_spec.rb
119
+ - spec/htmlunit_spec.rb
120
+ - spec/index_offset_spec.rb
121
+ - spec/listener_spec.rb
122
+ - spec/spec_helper.rb
123
+ - tasks/benchmark.rake
124
+ - tasks/deployment.rake
125
+ - tasks/environment.rake
126
+ - tasks/fix.rake
101
127
  - tasks/jar.rake
102
128
  - tasks/rdoc.rake
129
+ - tasks/rspec.rake
130
+ - tasks/simple_ci.rake
131
+ - tasks/snapshot.rake
132
+ - tasks/website.rake
133
+ - tasks/yard.rake
103
134
  has_rdoc: true
104
- homepage: http://celerity.rubyforge.org
135
+ homepage: http://celerity.rubyforge.org/
136
+ licenses: []
137
+
105
138
  post_install_message:
106
139
  rdoc_options:
107
140
  - --main
108
- - README.txt
141
+ - README.rdoc
109
142
  require_paths:
110
143
  - lib
111
144
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -123,9 +156,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
156
  requirements: []
124
157
 
125
158
  rubyforge_project: celerity
126
- rubygems_version: 1.3.1
159
+ rubygems_version: 1.3.5
127
160
  signing_key:
128
- specification_version: 2
161
+ specification_version: 3
129
162
  summary: Celerity is a JRuby library for easy and fast functional test automation for web applications
130
163
  test_files: []
131
164
 
data/README.txt DELETED
@@ -1,69 +0,0 @@
1
- = Celerity
2
-
3
- * http://celerity.rubyforge.org/
4
-
5
- == DESCRIPTION:
6
-
7
- Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with
8
- JavaScript support. It provides a simple API for programmatic navigation through
9
- web applications. Celerity aims at being API compatible with Watir.
10
-
11
- == FEATURES:
12
-
13
- * Fast: No time-consuming GUI rendering or unessential downloads
14
- * Scalable: Java threads lets you run tests in parallel
15
- * Easy to use: Simple API
16
- * Portable: Cross-platform
17
- * Unintrusive: No browser window interrupting your workflow (runs in background)
18
-
19
- == REQUIREMENTS:
20
-
21
- * JRuby 1.2.0 or higher
22
- * Java 6
23
-
24
- == INSTALL:
25
-
26
- `jruby -S gem install celerity`
27
-
28
- or from GitHub
29
-
30
- `jruby -S gem install jarib-celerity`
31
-
32
-
33
- == EXAMPLE:
34
-
35
- require "rubygems"
36
- require "celerity"
37
-
38
- browser = Celerity::Browser.new
39
- browser.goto('http://www.google.com')
40
- browser.text_field(:name, 'q').value = 'Celerity'
41
- browser.button(:name, 'btnG').click
42
-
43
- puts "yay" if browser.text.include? 'celerity.rubyforge.org'
44
-
45
- == SOURCE
46
-
47
- The source code is available at http://github.com/jarib/celerity/tree/master
48
-
49
- == WIKI:
50
-
51
- * http://github.com/jarib/celerity/wikis
52
-
53
- == LICENSE:
54
-
55
- Celerity - JRuby wrapper for HtmlUnit
56
- Copyright (c) 2008 FINN.no AS
57
-
58
- This program is free software: you can redistribute it and/or modify
59
- it under the terms of the GNU General Public License as published by
60
- the Free Software Foundation, either version 3 of the License, or
61
- (at your option) any later version.
62
-
63
- This program is distributed in the hope that it will be useful,
64
- but WITHOUT ANY WARRANTY; without even the implied warranty of
65
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66
- GNU General Public License for more details.
67
-
68
- You should have received a copy of the GNU General Public License
69
- along with this program. If not, see <http://www.gnu.org/licenses/>.