celerity 0.0.7 → 0.0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -40,8 +40,8 @@ lib/celerity/htmlunit/commons-io-1.4.jar
40
40
  lib/celerity/htmlunit/commons-lang-2.4.jar
41
41
  lib/celerity/htmlunit/commons-logging-1.1.1.jar
42
42
  lib/celerity/htmlunit/cssparser-0.9.5.jar
43
- lib/celerity/htmlunit/htmlunit-2.6.jar
44
- lib/celerity/htmlunit/htmlunit-core-js-2.6.jar
43
+ lib/celerity/htmlunit/htmlunit-2.7-SNAPSHOT.jar
44
+ lib/celerity/htmlunit/htmlunit-core-js-2.7-SNAPSHOT.jar
45
45
  lib/celerity/htmlunit/nekohtml-1.9.13.jar
46
46
  lib/celerity/htmlunit/sac-1.3.jar
47
47
  lib/celerity/htmlunit/serializer-2.7.1.jar
@@ -51,6 +51,7 @@ lib/celerity/htmlunit/xml-apis-1.3.04.jar
51
51
  lib/celerity/identifier.rb
52
52
  lib/celerity/ignoring_web_connection.rb
53
53
  lib/celerity/input_element.rb
54
+ lib/celerity/javascript_debugger.rb
54
55
  lib/celerity/listener.rb
55
56
  lib/celerity/resources/no_viewer.png
56
57
  lib/celerity/short_inspect.rb
@@ -76,7 +77,6 @@ tasks/fix.rake
76
77
  tasks/jar.rake
77
78
  tasks/rdoc.rake
78
79
  tasks/rspec.rake
79
- tasks/simple_ci.rake
80
80
  tasks/snapshot.rake
81
81
  tasks/website.rake
82
82
  tasks/yard.rake
data/README.rdoc CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  Celerity is a JRuby library for easy and fast functional test automation for web applications.
8
8
 
9
- It is a JRuby wrapper around HtmlUnit – a headless Java browser with
9
+ Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with
10
10
  JavaScript support. It provides a simple API for programmatic navigation through
11
- web applications. Celerity aims at being API compatible with Watir.
11
+ web applications. Celerity provides a superset of Watir's API.
12
12
 
13
13
  == Features
14
14
 
data/Rakefile CHANGED
@@ -10,11 +10,18 @@ Hoe.plugin :website
10
10
 
11
11
  # Generate all the Rake tasks
12
12
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- Hoe.spec 'celerity' do
14
- author << "Jari Bakken" << "T. Alexander Lystad" << "Knut Johannes Dahle"
15
- email << "jari.bakken@finn.no"
16
- extra_dev_deps << ['sinatra', '>= 0.9.4']
17
- version = Celerity::VERSION
13
+ Hoe.spec 'celerity' do |s|
14
+ s.developer "Jari Bakken", "jari.bakken@finn.no"
15
+ s.version = Celerity::VERSION
16
+ s.clean_globs = %w[classes/* pkg/ doc/*]
17
+
18
+ s.author << "Jari Bakken" << "T. Alexander Lystad" << "Knut Johannes Dahle"
19
+ s.email << "jari.bakken@finn.no"
20
+ s.extra_dev_deps << ['sinatra', '>= 0.9.4']
21
+ s.summary = "Celerity is a JRuby library for easy and fast functional test automation for web applications."
22
+
23
+ # hack to avoid the extra file
24
+ @website_config = {'host' => 'jarib@rubyforge.org', 'remote_dir' => "/var/www/gforge-projects/celerity"}
18
25
  end
19
26
 
20
27
  Dir['tasks/**/*.rake'].each do |rake|
data/celerity.gemspec CHANGED
@@ -2,25 +2,25 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{celerity}
5
- s.version = "0.0.7"
5
+ s.version = "0.0.7.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
9
- s.date = %q{2009-09-04}
8
+ s.authors = ["Jari Bakken", "Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
9
+ s.date = %q{2009-09-30}
10
10
  s.description = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications.
11
11
 
12
- It is a JRuby wrapper around HtmlUnit – a headless Java browser with
12
+ Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with
13
13
  JavaScript support. It provides a simple API for programmatic navigation through
14
- web applications. Celerity aims at being API compatible with Watir.}
15
- s.email = ["jari.bakken@finn.no"]
14
+ web applications. Celerity provides a superset of Watir's API.}
15
+ s.email = ["jari.bakken@finn.no", "jari.bakken@finn.no"]
16
16
  s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt"]
17
- s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "celerity.gemspec", "lib/celerity.rb", "lib/celerity/browser.rb", "lib/celerity/clickable_element.rb", "lib/celerity/collections.rb", "lib/celerity/container.rb", "lib/celerity/default_viewer.rb", "lib/celerity/disabled_element.rb", "lib/celerity/element.rb", "lib/celerity/element_collection.rb", "lib/celerity/element_locator.rb", "lib/celerity/elements/button.rb", "lib/celerity/elements/file_field.rb", "lib/celerity/elements/form.rb", "lib/celerity/elements/frame.rb", "lib/celerity/elements/image.rb", "lib/celerity/elements/label.rb", "lib/celerity/elements/link.rb", "lib/celerity/elements/meta.rb", "lib/celerity/elements/non_control_elements.rb", "lib/celerity/elements/option.rb", "lib/celerity/elements/radio_check.rb", "lib/celerity/elements/select_list.rb", "lib/celerity/elements/table.rb", "lib/celerity/elements/table_cell.rb", "lib/celerity/elements/table_elements.rb", "lib/celerity/elements/table_row.rb", "lib/celerity/elements/text_field.rb", "lib/celerity/exception.rb", "lib/celerity/htmlunit.rb", "lib/celerity/htmlunit/commons-codec-1.4.jar", "lib/celerity/htmlunit/commons-collections-3.2.1.jar", "lib/celerity/htmlunit/commons-httpclient-3.1.jar", "lib/celerity/htmlunit/commons-io-1.4.jar", "lib/celerity/htmlunit/commons-lang-2.4.jar", "lib/celerity/htmlunit/commons-logging-1.1.1.jar", "lib/celerity/htmlunit/cssparser-0.9.5.jar", "lib/celerity/htmlunit/htmlunit-2.6.jar", "lib/celerity/htmlunit/htmlunit-core-js-2.6.jar", "lib/celerity/htmlunit/nekohtml-1.9.13.jar", "lib/celerity/htmlunit/sac-1.3.jar", "lib/celerity/htmlunit/serializer-2.7.1.jar", "lib/celerity/htmlunit/xalan-2.7.1.jar", "lib/celerity/htmlunit/xercesImpl-2.9.1.jar", "lib/celerity/htmlunit/xml-apis-1.3.04.jar", "lib/celerity/identifier.rb", "lib/celerity/ignoring_web_connection.rb", "lib/celerity/input_element.rb", "lib/celerity/listener.rb", "lib/celerity/resources/no_viewer.png", "lib/celerity/short_inspect.rb", "lib/celerity/util.rb", "lib/celerity/version.rb", "lib/celerity/viewer_connection.rb", "lib/celerity/watir_compatibility.rb", "lib/celerity/xpath_support.rb", "spec/browser_authentication_spec.rb", "spec/browser_spec.rb", "spec/clickable_element_spec.rb", "spec/default_viewer_spec.rb", "spec/element_spec.rb", "spec/filefield_spec.rb", "spec/htmlunit_spec.rb", "spec/index_offset_spec.rb", "spec/listener_spec.rb", "spec/spec_helper.rb", "tasks/benchmark.rake", "tasks/deployment.rake", "tasks/environment.rake", "tasks/fix.rake", "tasks/jar.rake", "tasks/rdoc.rake", "tasks/rspec.rake", "tasks/simple_ci.rake", "tasks/snapshot.rake", "tasks/website.rake", "tasks/yard.rake"]
17
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "celerity.gemspec", "lib/celerity.rb", "lib/celerity/browser.rb", "lib/celerity/clickable_element.rb", "lib/celerity/collections.rb", "lib/celerity/container.rb", "lib/celerity/default_viewer.rb", "lib/celerity/disabled_element.rb", "lib/celerity/element.rb", "lib/celerity/element_collection.rb", "lib/celerity/element_locator.rb", "lib/celerity/elements/button.rb", "lib/celerity/elements/file_field.rb", "lib/celerity/elements/form.rb", "lib/celerity/elements/frame.rb", "lib/celerity/elements/image.rb", "lib/celerity/elements/label.rb", "lib/celerity/elements/link.rb", "lib/celerity/elements/meta.rb", "lib/celerity/elements/non_control_elements.rb", "lib/celerity/elements/option.rb", "lib/celerity/elements/radio_check.rb", "lib/celerity/elements/select_list.rb", "lib/celerity/elements/table.rb", "lib/celerity/elements/table_cell.rb", "lib/celerity/elements/table_elements.rb", "lib/celerity/elements/table_row.rb", "lib/celerity/elements/text_field.rb", "lib/celerity/exception.rb", "lib/celerity/htmlunit.rb", "lib/celerity/htmlunit/commons-codec-1.4.jar", "lib/celerity/htmlunit/commons-collections-3.2.1.jar", "lib/celerity/htmlunit/commons-httpclient-3.1.jar", "lib/celerity/htmlunit/commons-io-1.4.jar", "lib/celerity/htmlunit/commons-lang-2.4.jar", "lib/celerity/htmlunit/commons-logging-1.1.1.jar", "lib/celerity/htmlunit/cssparser-0.9.5.jar", "lib/celerity/htmlunit/htmlunit-2.7-SNAPSHOT.jar", "lib/celerity/htmlunit/htmlunit-core-js-2.7-SNAPSHOT.jar", "lib/celerity/htmlunit/nekohtml-1.9.13.jar", "lib/celerity/htmlunit/sac-1.3.jar", "lib/celerity/htmlunit/serializer-2.7.1.jar", "lib/celerity/htmlunit/xalan-2.7.1.jar", "lib/celerity/htmlunit/xercesImpl-2.9.1.jar", "lib/celerity/htmlunit/xml-apis-1.3.04.jar", "lib/celerity/identifier.rb", "lib/celerity/ignoring_web_connection.rb", "lib/celerity/input_element.rb", "lib/celerity/javascript_debugger.rb", "lib/celerity/listener.rb", "lib/celerity/resources/no_viewer.png", "lib/celerity/short_inspect.rb", "lib/celerity/util.rb", "lib/celerity/version.rb", "lib/celerity/viewer_connection.rb", "lib/celerity/watir_compatibility.rb", "lib/celerity/xpath_support.rb", "spec/browser_authentication_spec.rb", "spec/browser_spec.rb", "spec/clickable_element_spec.rb", "spec/default_viewer_spec.rb", "spec/element_spec.rb", "spec/filefield_spec.rb", "spec/htmlunit_spec.rb", "spec/index_offset_spec.rb", "spec/listener_spec.rb", "spec/spec_helper.rb", "tasks/benchmark.rake", "tasks/deployment.rake", "tasks/environment.rake", "tasks/fix.rake", "tasks/jar.rake", "tasks/rdoc.rake", "tasks/rspec.rake", "tasks/snapshot.rake", "tasks/website.rake", "tasks/yard.rake"]
18
18
  s.homepage = %q{http://celerity.rubyforge.org/}
19
19
  s.rdoc_options = ["--main", "README.rdoc"]
20
20
  s.require_paths = ["lib"]
21
21
  s.rubyforge_project = %q{celerity}
22
22
  s.rubygems_version = %q{1.3.5}
23
- s.summary = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications}
23
+ s.summary = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications.}
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
data/lib/celerity.rb CHANGED
@@ -67,6 +67,7 @@ require "celerity/util"
67
67
  require "celerity/default_viewer"
68
68
  require "celerity/listener"
69
69
  require "celerity/ignoring_web_connection"
70
+ require "celerity/javascript_debugger"
70
71
  require "celerity/viewer_connection"
71
72
  require "celerity/browser"
72
73
  require "celerity/watir_compatibility"
@@ -32,7 +32,7 @@ module Celerity
32
32
  #
33
33
  # @see Celerity::Container for an introduction to the main API.
34
34
  #
35
- # @option opts :browser [:internet_explorer, :firefox, :firefox3] (:firefox) Set the BrowserVersion used by HtmlUnit. Defaults to Firefox 2.
35
+ # @option opts :browser [:internet_explorer, :firefox, :firefox3] (:firefox3) Set the BrowserVersion used by HtmlUnit. Defaults to Firefox 3.
36
36
  # @option opts :charset [String] ("UTF-8") Specify the charset that webclient will use for requests, and those where texts are getting gibberished, like Browser#html.
37
37
  # @option opts :css [Boolean] (false) Enable CSS. Disabled by default.
38
38
  # @option opts :ignore_pattern [Regexp] See Browser#ignore_pattern=
@@ -333,19 +333,21 @@ module Celerity
333
333
  # @param [String] value
334
334
  #
335
335
  # @option opts :path [String] ("/") A path
336
- # @option opts :max_age [Fixnum] (??) A max age
336
+ # @option opts :expires [Time] (1 day from now) An expiration date
337
337
  # @option opts :secure [Boolean] (false)
338
338
  #
339
339
 
340
340
  def add_cookie(domain, name, value, opts = {})
341
341
  path = opts.delete(:path) || "/"
342
- max_age = opts.delete(:max_age) || (Time.now + 60*60*24) # not sure if this is correct
342
+ expires = opts.delete(:expires) || (Time.now + 60*60*24) # not sure if this is correct
343
343
  secure = opts.delete(:secure) || false
344
344
 
345
345
  raise(ArgumentError, "unknown option: #{opts.inspect}") unless opts.empty?
346
346
 
347
- cookie = Cookie.new(domain, name, value, path, max_age, secure)
348
- @webclient.getCookieManager.addCookie(cookie)
347
+ cookie = HtmlUnit::Util::Cookie.new(name, value, domain, path, expires, secure)
348
+ @webclient.getCookieManager.addCookie cookie
349
+
350
+ cookie
349
351
  end
350
352
 
351
353
  #
@@ -489,6 +491,12 @@ module Celerity
489
491
  res
490
492
  end
491
493
 
494
+ def trace_javascript(debugger_klass = Celerity::JavascriptDebugger, &blk)
495
+ @webclient.getJavaScriptEngine.getContextFactory.setDebugger debugger_klass.new
496
+ yield
497
+ @webclient.getJavaScriptEngine.getContextFactory.setDebugger nil
498
+ end
499
+
492
500
  #
493
501
  # Add a listener block for one of the available types. (Celerity only)
494
502
  # Types map to HtmlUnit interfaces like this:
@@ -799,7 +807,7 @@ module Celerity
799
807
  #
800
808
 
801
809
  def setup_webclient(opts)
802
- browser = (opts.delete(:browser) || :firefox).to_sym
810
+ browser = (opts.delete(:browser) || :firefox3).to_sym
803
811
 
804
812
  browser_version = case browser
805
813
  when :firefox, :ff, :ff2
@@ -827,7 +835,7 @@ module Celerity
827
835
  self.status_code_exceptions = false unless opts.delete(:status_code_exceptions)
828
836
  self.css = false unless opts.delete(:css)
829
837
  self.javascript_enabled = opts.delete(:javascript_enabled) != false
830
- self.secure_ssl = opts.delete(:secure_ssl) == false
838
+ self.secure_ssl = opts.delete(:secure_ssl) != false
831
839
  self.ignore_pattern = opts.delete(:ignore_pattern) if opts[:ignore_pattern]
832
840
  self.refresh_handler = opts.delete(:refresh_handler) if opts[:refresh_handler]
833
841
 
@@ -118,6 +118,14 @@ module Celerity
118
118
  'select-' + (@object.hasAttribute('multiple') ? 'multiple' : 'one')
119
119
  end
120
120
 
121
+ #
122
+ # Returns true if the select list supports multiple selections
123
+ #
124
+
125
+ def multiple?
126
+ type == "select-multiple"
127
+ end
128
+
121
129
  #
122
130
  # Returns the value of the first selected option in the select list.
123
131
  # Returns nil if no option is selected.
@@ -2,8 +2,6 @@ module Celerity
2
2
  Jars = Dir[File.dirname(__FILE__) + '/htmlunit/*.jar']
3
3
  Jars.each { |jar| require(jar) }
4
4
 
5
- include_class org.apache.commons.httpclient.Cookie
6
-
7
5
  module JsxHelper
8
6
  def method_missing(meth, *args, &blk)
9
7
  m = ["jsxGet_#{meth}", "jsx_get_#{meth}"].find { |m| respond_to?(m) }
@@ -22,6 +20,7 @@ module HtmlUnit
22
20
  module Util
23
21
  include_package 'com.gargoylesoftware.htmlunit.util'
24
22
  end
23
+
25
24
  end
26
25
 
27
26
  module Java::OrgW3cDom::NamedNodeMap
@@ -0,0 +1,32 @@
1
+ module Celerity
2
+ class JavascriptDebugger
3
+ include Java::net.sourceforge.htmlunit.corejs.javascript.debug.Debugger
4
+
5
+ def handleCompilationDone(ctx, script, source)
6
+ p debug_info_for(script).merge(:source_code => source)
7
+ end
8
+
9
+ def getFrame(ctx, script)
10
+ p debug_info_for(script)
11
+ end
12
+
13
+ private
14
+
15
+ def string_for_context(ctx)
16
+ ctx.toString
17
+ end
18
+
19
+ def string_for_script(script)
20
+ script.toString
21
+ end
22
+
23
+ def debug_info_for(script)
24
+ {
25
+ :source => "#{script.getSourceName}:#{script.getLineNumbers.to_a.join(",")}",
26
+ :function_name => script.getFunctionName,
27
+ :params => (0...script.getParamAndVarCount).map { |idx| script.getParamOrVarName(idx) },
28
+ :function? => script.isFunction,
29
+ }
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Celerity
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.7.2"
3
3
  end
data/spec/browser_spec.rb CHANGED
@@ -149,7 +149,7 @@ describe "Browser" do
149
149
  end
150
150
 
151
151
  it "adds a cookie with the specified options" do
152
- browser.add_cookie("example.com", "foo", "bar", :path => "/foobar", :max_age => 1000)
152
+ browser.add_cookie("example.com", "foo", "bar", :path => "/foobar", :expires => Time.now + 100000)
153
153
  cookies = browser.cookies
154
154
  cookies.should be_instance_of(Hash)
155
155
  cookies['example.com']['foo'].should == 'bar'
data/tasks/snapshot.rake CHANGED
@@ -1,6 +1,6 @@
1
1
  desc 'Download and unpack the latest HtmlUnit assembly'
2
2
  task :snapshot do
3
- files = %w[ http://build.canoo.com/htmlunit/artifacts/htmlunit-2.6-SNAPSHOT-with-dependencies.zip ]
3
+ files = %w[ http://build.canoo.com/htmlunit/artifacts/htmlunit-2.7-SNAPSHOT-with-dependencies.zip ]
4
4
 
5
5
  files.each do |url|
6
6
  basename = File.basename(url)
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
+ - Jari Bakken
8
9
  - T. Alexander Lystad
9
10
  - Knut Johannes Dahle
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
14
 
14
- date: 2009-09-04 00:00:00 +02:00
15
+ date: 2009-10-07 00:00:00 +02:00
15
16
  default_executable:
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
@@ -34,12 +35,10 @@ dependencies:
34
35
  - !ruby/object:Gem::Version
35
36
  version: 2.3.3
36
37
  version:
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."
38
+ description: ""
41
39
  email:
42
40
  - jari.bakken@finn.no
41
+ - jari.bakken@finn.no
43
42
  executables: []
44
43
 
45
44
  extensions: []
@@ -91,8 +90,8 @@ files:
91
90
  - lib/celerity/htmlunit/commons-lang-2.4.jar
92
91
  - lib/celerity/htmlunit/commons-logging-1.1.1.jar
93
92
  - lib/celerity/htmlunit/cssparser-0.9.5.jar
94
- - lib/celerity/htmlunit/htmlunit-2.6.jar
95
- - lib/celerity/htmlunit/htmlunit-core-js-2.6.jar
93
+ - lib/celerity/htmlunit/htmlunit-2.7-SNAPSHOT.jar
94
+ - lib/celerity/htmlunit/htmlunit-core-js-2.7-SNAPSHOT.jar
96
95
  - lib/celerity/htmlunit/nekohtml-1.9.13.jar
97
96
  - lib/celerity/htmlunit/sac-1.3.jar
98
97
  - lib/celerity/htmlunit/serializer-2.7.1.jar
@@ -102,6 +101,7 @@ files:
102
101
  - lib/celerity/identifier.rb
103
102
  - lib/celerity/ignoring_web_connection.rb
104
103
  - lib/celerity/input_element.rb
104
+ - lib/celerity/javascript_debugger.rb
105
105
  - lib/celerity/listener.rb
106
106
  - lib/celerity/resources/no_viewer.png
107
107
  - lib/celerity/short_inspect.rb
@@ -127,18 +127,17 @@ files:
127
127
  - tasks/jar.rake
128
128
  - tasks/rdoc.rake
129
129
  - tasks/rspec.rake
130
- - tasks/simple_ci.rake
131
130
  - tasks/snapshot.rake
132
131
  - tasks/website.rake
133
132
  - tasks/yard.rake
134
133
  has_rdoc: true
135
- homepage: http://celerity.rubyforge.org/
134
+ homepage:
136
135
  licenses: []
137
136
 
138
137
  post_install_message:
139
138
  rdoc_options:
140
139
  - --main
141
- - README.rdoc
140
+ - README.txt
142
141
  require_paths:
143
142
  - lib
144
143
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -159,6 +158,6 @@ rubyforge_project: celerity
159
158
  rubygems_version: 1.3.5
160
159
  signing_key:
161
160
  specification_version: 3
162
- summary: Celerity is a JRuby library for easy and fast functional test automation for web applications
161
+ summary: Celerity is a JRuby library for easy and fast functional test automation for web applications.
163
162
  test_files: []
164
163
 
Binary file
data/tasks/simple_ci.rake DELETED
@@ -1,94 +0,0 @@
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
-