akephalos 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT_LICENSE +20 -0
- data/README.md +55 -0
- data/bin/akephalos +56 -8
- data/lib/akephalos.rb +5 -0
- data/lib/akephalos/client.rb +4 -1
- data/lib/akephalos/console.rb +1 -1
- data/lib/akephalos/htmlunit.rb +12 -16
- data/lib/akephalos/remote_client.rb +40 -10
- data/lib/akephalos/server.rb +5 -4
- data/lib/akephalos/version.rb +3 -0
- data/src/{commons-codec-1.4.jar → htmlunit/commons-codec-1.4.jar} +0 -0
- data/src/{commons-collections-3.2.1.jar → htmlunit/commons-collections-3.2.1.jar} +0 -0
- data/src/{commons-httpclient-3.1.jar → htmlunit/commons-httpclient-3.1.jar} +0 -0
- data/src/{commons-io-1.4.jar → htmlunit/commons-io-1.4.jar} +0 -0
- data/src/{commons-lang-2.4.jar → htmlunit/commons-lang-2.4.jar} +0 -0
- data/src/{commons-logging-1.1.1.jar → htmlunit/commons-logging-1.1.1.jar} +0 -0
- data/src/{cssparser-0.9.5.jar → htmlunit/cssparser-0.9.5.jar} +0 -0
- data/src/{htmlunit-2.7.jar → htmlunit/htmlunit-2.7.jar} +0 -0
- data/src/{htmlunit-core-js-2.7.jar → htmlunit/htmlunit-core-js-2.7.jar} +0 -0
- data/src/{nekohtml-1.9.14.jar → htmlunit/nekohtml-1.9.14.jar} +0 -0
- data/src/{sac-1.3.jar → htmlunit/sac-1.3.jar} +0 -0
- data/src/{serializer-2.7.1.jar → htmlunit/serializer-2.7.1.jar} +0 -0
- data/src/{xalan-2.7.1.jar → htmlunit/xalan-2.7.1.jar} +0 -0
- data/src/{xercesImpl-2.9.1.jar → htmlunit/xercesImpl-2.9.1.jar} +0 -0
- data/src/{xml-apis-1.3.04.jar → htmlunit/xml-apis-1.3.04.jar} +0 -0
- metadata +59 -60
- data/.gitignore +0 -4
- data/README +0 -23
- data/Rakefile +0 -37
- data/TODO.txt +0 -33
- data/VERSION +0 -1
- data/akephalos.gemspec +0 -97
- data/spec/driver/akephalos_driver_spec.rb +0 -12
- data/spec/filter_spec.rb +0 -24
- data/spec/session/akephalos_session_spec.rb +0 -26
- data/spec/slow_page_loads_spec.rb +0 -66
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -12
- data/src/jruby-complete-1.5.0.jar +0 -0
data/MIT_LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Bernerd Schaefer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Akephalos
|
2
|
+
Akephalos is a full-stack headless browser for integration testing with
|
3
|
+
Capybara. It is built on top of [HtmlUnit](http://htmlunit.sourceforge.com),
|
4
|
+
a GUI-less browser for the Java platform, but can be run on both JRuby and
|
5
|
+
MRI with no need for JRuby to be installed on the system.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install akephalos
|
10
|
+
|
11
|
+
## Setup
|
12
|
+
|
13
|
+
Configuring akephalos is as simple as requiring it and setting Capybara's
|
14
|
+
javascript driver:
|
15
|
+
|
16
|
+
require 'akephalos'
|
17
|
+
Capybara.javascript_driver = :akephalos
|
18
|
+
|
19
|
+
## Basic Usage
|
20
|
+
|
21
|
+
Akephalos provides a driver for Capybara, so using Akephalos is no
|
22
|
+
different than using Selenium or Rack::Test. For a full usage guide, check
|
23
|
+
out Capybara's DSL [documentation](http://github.com/jnicklas/capybara). It
|
24
|
+
makes no assumptions about the testing framework being used, and works with
|
25
|
+
RSpec, Cucumber, and Test::Unit.
|
26
|
+
|
27
|
+
Here's some sample RSpec code:
|
28
|
+
|
29
|
+
describe "Home Page" do
|
30
|
+
before { visit "/" }
|
31
|
+
context "searching" do
|
32
|
+
before do
|
33
|
+
fill_in "Search", :with => "akephalos"
|
34
|
+
click_button "Go"
|
35
|
+
end
|
36
|
+
it "returns results" { page.should have_css("#results") }
|
37
|
+
it "includes the search term" { page.should have_content("akephalos") }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
## More
|
42
|
+
|
43
|
+
* [bin/akephalos](http://bernerdschaefer.github.com/akephalos/akephalos-bin.html)
|
44
|
+
allows you to start an interactive shell or DRb server, as well as perform
|
45
|
+
other maintenance features.
|
46
|
+
|
47
|
+
* [Filters](http://bernerdschaefer.github.com/akephalos/filters.html) allows
|
48
|
+
you to declare mock responses for external resources and services requested
|
49
|
+
by the browser.
|
50
|
+
|
51
|
+
## Resources
|
52
|
+
|
53
|
+
* [Source code](http://github.com/bernerdschaefer/akephalos) and
|
54
|
+
[issues](http://github.com/bernerdschaefer/akephalos/issues) are hosted on
|
55
|
+
github.
|
data/bin/akephalos
CHANGED
@@ -7,9 +7,10 @@ require "optparse"
|
|
7
7
|
options = { :interactive => false }
|
8
8
|
|
9
9
|
parser = OptionParser.new do |opts|
|
10
|
-
opts.banner = "Usage: akephalos [--interactive] | [--server] <socket_file>"
|
10
|
+
opts.banner = "Usage: akephalos [--interactive, --use-htmlunit-snapshot] | [--server] <socket_file>"
|
11
11
|
opts.on("-s", "--server", "Run in server mode (default)")
|
12
12
|
opts.on("-i", "--interactive", "Run in interactive mode") { options[:interactive] = true }
|
13
|
+
opts.on("--use-htmlunit-snapshot", "Use the snapshot of htmlunit") { options[:use_htmlunit_snapshot] = true }
|
13
14
|
|
14
15
|
opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
|
15
16
|
end
|
@@ -17,11 +18,33 @@ parser.parse!
|
|
17
18
|
|
18
19
|
root = Pathname(__FILE__).expand_path.dirname.parent
|
19
20
|
lib = root + 'lib'
|
20
|
-
|
21
|
-
jruby_cmd = %Q(java -Xmx2048M -jar #{jruby} -I#{lib})
|
21
|
+
src = root + 'src'
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
case
|
24
|
+
when options[:use_htmlunit_snapshot]
|
25
|
+
require "fileutils"
|
26
|
+
|
27
|
+
FileUtils.mkdir_p("vendor/htmlunit")
|
28
|
+
Dir["vendor/htmlunit/*.jar"].each { |jar| File.unlink(jar) }
|
29
|
+
|
30
|
+
Dir.chdir("vendor") do
|
31
|
+
$stdout.print "Downloading latest snapshot... "
|
32
|
+
$stdout.flush
|
33
|
+
%x[curl -O http://build.canoo.com/htmlunit/artifacts/htmlunit-2.8-SNAPSHOT-with-dependencies.zip &> /dev/null]
|
34
|
+
puts "done"
|
35
|
+
|
36
|
+
$stdout.print "Extracting dependencies... "
|
37
|
+
$stdout.flush
|
38
|
+
%x[unzip -j -d htmlunit htmlunit-2.8-SNAPSHOT-with-dependencies.zip htmlunit-2.8-SNAPSHOT/lib htmlunit-2.8-SNAPSHOT/lib/* &> /dev/null]
|
39
|
+
puts "done"
|
40
|
+
|
41
|
+
File.unlink "htmlunit-2.8-SNAPSHOT-with-dependencies.zip"
|
42
|
+
end
|
43
|
+
|
44
|
+
$stdout.puts "="*40
|
45
|
+
$stdout.puts "The latest HtmlUnit snapshot has been extracted to vendor/htmlunit!"
|
46
|
+
when options[:interactive]
|
47
|
+
$:.unshift('vendor', lib, src)
|
25
48
|
require 'rubygems'
|
26
49
|
require 'akephalos'
|
27
50
|
require 'akephalos/console'
|
@@ -32,8 +55,33 @@ else
|
|
32
55
|
exit
|
33
56
|
end
|
34
57
|
|
35
|
-
|
58
|
+
if RUBY_PLATFORM == "java"
|
59
|
+
$:.unshift("vendor", lib, src)
|
60
|
+
require 'akephalos/server'
|
61
|
+
Akephalos::Server.start!(socket_file)
|
62
|
+
else
|
63
|
+
require 'rubygems'
|
64
|
+
require 'jruby-jars'
|
65
|
+
|
66
|
+
jruby = JRubyJars.core_jar_path
|
67
|
+
jruby_stdlib = JRubyJars.stdlib_jar_path
|
36
68
|
|
37
|
-
|
38
|
-
|
69
|
+
java_args = [
|
70
|
+
"-Xmx128M",
|
71
|
+
"-cp", [JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path].join(":"),
|
72
|
+
"org.jruby.Main"
|
73
|
+
]
|
74
|
+
ruby_args = [
|
75
|
+
"-I", "vendor:#{lib}:#{src}",
|
76
|
+
"-r", "akephalos/server",
|
77
|
+
"-e", "Akephalos::Server.start!(#{socket_file.inspect})"
|
78
|
+
]
|
79
|
+
|
80
|
+
# Bundler sets ENV["RUBYOPT"] to automatically load bundler/setup.rb, but
|
81
|
+
# since the akephalos server doesn't have any gem dependencies and is
|
82
|
+
# always executed with the same context, we clear RUBYOPT before running
|
83
|
+
# exec.
|
84
|
+
ENV["RUBYOPT"] = ""
|
85
|
+
exec("java", *(java_args + ruby_args))
|
86
|
+
end
|
39
87
|
end
|
data/lib/akephalos.rb
CHANGED
data/lib/akephalos/client.rb
CHANGED
@@ -40,6 +40,7 @@ else
|
|
40
40
|
|
41
41
|
def visit(url)
|
42
42
|
client.getPage(url)
|
43
|
+
page
|
43
44
|
end
|
44
45
|
|
45
46
|
def page=(_page)
|
@@ -51,7 +52,9 @@ else
|
|
51
52
|
|
52
53
|
private
|
53
54
|
def client
|
54
|
-
@client ||= @_client.get
|
55
|
+
@client ||= @_client.get.tap do |client|
|
56
|
+
client.getCurrentWindow.getHistory.ignoreNewPages_.set(true)
|
57
|
+
end
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/akephalos/console.rb
CHANGED
data/lib/akephalos/htmlunit.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "java"
|
3
3
|
|
4
|
-
$:.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require
|
10
|
-
|
11
|
-
require "cssparser-0.9.5.jar"
|
12
|
-
require "htmlunit-2.7.jar"
|
13
|
-
require "htmlunit-core-js-2.7.jar"
|
14
|
-
require "nekohtml-1.9.14.jar"
|
15
|
-
require "sac-1.3.jar"
|
16
|
-
require "serializer-2.7.1.jar"
|
17
|
-
require "xalan-2.7.1.jar"
|
18
|
-
require "xercesImpl-2.9.1.jar"
|
19
|
-
require "xml-apis-1.3.04.jar"
|
4
|
+
dependency_directory = $:.detect { |path| Dir[File.join(path, 'htmlunit/htmlunit-*.jar')].any? }
|
5
|
+
|
6
|
+
raise "Could not find htmlunit/htmlunit-VERSION.jar in load path:\n [ #{$:.join(",\n ")}\n ]" unless dependency_directory
|
7
|
+
|
8
|
+
Dir[File.join(dependency_directory, "htmlunit/*.jar")].each do |jar|
|
9
|
+
require jar
|
10
|
+
end
|
20
11
|
|
21
12
|
java.lang.System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog")
|
22
13
|
java.lang.System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "fatal")
|
@@ -26,6 +17,11 @@ java_import "com.gargoylesoftware.htmlunit.WebClient"
|
|
26
17
|
java_import "com.gargoylesoftware.htmlunit.util.WebConnectionWrapper"
|
27
18
|
java_import 'com.gargoylesoftware.htmlunit.HttpMethod'
|
28
19
|
|
20
|
+
|
21
|
+
# Disable history tracking
|
22
|
+
com.gargoylesoftware.htmlunit.History.field_reader :ignoreNewPages_
|
23
|
+
|
24
|
+
# Run in Firefox compatibility mode
|
29
25
|
com.gargoylesoftware.htmlunit.BrowserVersion.setDefault(
|
30
26
|
com.gargoylesoftware.htmlunit.BrowserVersion::FIREFOX_3
|
31
27
|
)
|
@@ -1,27 +1,57 @@
|
|
1
1
|
require 'drb/drb'
|
2
2
|
|
3
|
-
|
3
|
+
# We need to define our own NativeException class for the cases when a native
|
4
|
+
# exception is raised by the JRuby DRb server.
|
5
|
+
class NativeException < StandardError; end # :nodoc:
|
4
6
|
|
5
7
|
module Akephalos
|
8
|
+
##
|
9
|
+
# The +RemoteClient+ class provides an interface to an +Akephalos::Client+
|
10
|
+
# isntance on a remote DRb server.
|
11
|
+
#
|
12
|
+
# == Usage
|
13
|
+
# client = Akephalos::RemoteClient.new
|
14
|
+
# client.visit "http://www.oinopa.com"
|
15
|
+
# client.page.source # => "<!DOCTYPE html PUBLIC..."
|
6
16
|
class RemoteClient
|
7
17
|
@socket_file = "/tmp/akephalos.#{Process.pid}.sock"
|
8
18
|
|
19
|
+
##
|
20
|
+
# Starts a remote akephalos server and returns the remote Akephalos::Client
|
21
|
+
# instance.
|
22
|
+
def self.new
|
23
|
+
start!
|
24
|
+
DRb.start_service
|
25
|
+
client = DRbObject.new_with_uri("drbunix://#{@socket_file}")
|
26
|
+
# We want to share our local configuration with the remote server
|
27
|
+
# process, so we share an undumped version of our configuration. This
|
28
|
+
# lets us continue to make changes locally and have them reflected in the
|
29
|
+
# remote process.
|
30
|
+
client.configuration = Akephalos.configuration.extend(DRbUndumped)
|
31
|
+
client
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Start a remote server process, returning when it is available for use.
|
9
36
|
def self.start!
|
10
37
|
remote_client = fork do
|
11
38
|
exec("#{Akephalos::BIN_DIR + 'akephalos'} #{@socket_file}")
|
12
39
|
end
|
13
40
|
|
14
|
-
|
41
|
+
# Set up a monitor thread to detect if the forked server exits
|
42
|
+
# prematurely.
|
43
|
+
server_monitor = Thread.new { Thread.current[:exited] = Process.wait }
|
15
44
|
|
16
|
-
|
17
|
-
|
45
|
+
# Wait for the server to be accessible on the socket we specified.
|
46
|
+
until File.exists?(@socket_file)
|
47
|
+
exit!(1) if server_monitor[:exited]
|
48
|
+
sleep 1
|
49
|
+
end
|
50
|
+
server_monitor.kill
|
18
51
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
client = DRbObject.new_with_uri("drbunix://#{@socket_file}")
|
23
|
-
client.configuration = Akephalos.configuration.extend(DRbUndumped)
|
24
|
-
client
|
52
|
+
# Ensure that the remote server shuts down gracefully when we are
|
53
|
+
# finished.
|
54
|
+
at_exit { Process.kill(:INT, remote_client); File.unlink(@socket_file) }
|
25
55
|
end
|
26
56
|
end
|
27
57
|
end
|
data/lib/akephalos/server.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
+
# This file runs a JRuby DRb server, and is run by `akephalos --server`.
|
1
2
|
require "pathname"
|
2
3
|
require "drb/drb"
|
3
4
|
require "akephalos/client"
|
4
5
|
|
6
|
+
# In ruby-1.8.7 and later, the message for a NameError exception is lazily
|
7
|
+
# evaluated. There are, however, different implementations of this between ruby
|
8
|
+
# and jrby, so we realize these messages when sending over DRb.
|
5
9
|
class NameError::Message
|
6
10
|
def _dump
|
7
11
|
to_s
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
|
-
[
|
12
|
-
Akephalos::Page,
|
13
|
-
Akephalos::Node
|
14
|
-
].each { |klass| klass.send(:include, DRbUndumped) }
|
15
|
+
[Akephalos::Page, Akephalos::Node].each { |klass| klass.send(:include, DRbUndumped) }
|
15
16
|
|
16
17
|
module Akephalos
|
17
18
|
class Server
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.5
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bernerd Schaefer
|
@@ -14,8 +14,8 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
18
|
-
default_executable:
|
17
|
+
date: 2010-07-26 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: capybara
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: jruby-jars
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
@@ -41,83 +41,84 @@ dependencies:
|
|
41
41
|
segments:
|
42
42
|
- 0
|
43
43
|
version: "0"
|
44
|
-
type: :
|
44
|
+
type: :runtime
|
45
45
|
version_requirements: *id002
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: sinatra
|
48
48
|
prerelease: false
|
49
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
segments:
|
54
|
-
- 1
|
55
|
-
- 3
|
56
54
|
- 0
|
57
|
-
version:
|
55
|
+
version: "0"
|
58
56
|
type: :development
|
59
57
|
version_requirements: *id003
|
60
|
-
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - "="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 1
|
67
|
+
- 30
|
68
|
+
version: "1.30"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id004
|
71
|
+
description: Headless Browser for Integration Testing with Capybara
|
61
72
|
email: bj.schaefer@gmail.com
|
62
73
|
executables:
|
63
74
|
- akephalos
|
64
75
|
extensions: []
|
65
76
|
|
66
|
-
extra_rdoc_files:
|
67
|
-
|
77
|
+
extra_rdoc_files: []
|
78
|
+
|
68
79
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- README
|
71
|
-
- Rakefile
|
72
|
-
- TODO.txt
|
73
|
-
- VERSION
|
74
|
-
- akephalos.gemspec
|
75
|
-
- bin/akephalos
|
76
|
-
- lib/akephalos.rb
|
77
80
|
- lib/akephalos/capybara.rb
|
78
|
-
- lib/akephalos/client.rb
|
79
81
|
- lib/akephalos/client/filter.rb
|
80
82
|
- lib/akephalos/client/listener.rb
|
83
|
+
- lib/akephalos/client.rb
|
81
84
|
- lib/akephalos/configuration.rb
|
82
85
|
- lib/akephalos/console.rb
|
83
86
|
- lib/akephalos/cucumber.rb
|
84
|
-
- lib/akephalos/htmlunit.rb
|
85
87
|
- lib/akephalos/htmlunit/ext/http_method.rb
|
88
|
+
- lib/akephalos/htmlunit.rb
|
86
89
|
- lib/akephalos/node.rb
|
87
90
|
- lib/akephalos/page.rb
|
88
91
|
- lib/akephalos/remote_client.rb
|
89
92
|
- lib/akephalos/server.rb
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
- src/commons-
|
97
|
-
- src/commons-
|
98
|
-
- src/
|
99
|
-
- src/
|
100
|
-
- src/
|
101
|
-
- src/
|
102
|
-
- src/
|
103
|
-
- src/htmlunit-2.7.jar
|
104
|
-
- src/htmlunit-
|
105
|
-
- src/
|
106
|
-
- src/
|
107
|
-
-
|
108
|
-
-
|
109
|
-
- src/xalan-2.7.1.jar
|
110
|
-
- src/xercesImpl-2.9.1.jar
|
111
|
-
- src/xml-apis-1.3.04.jar
|
93
|
+
- lib/akephalos/version.rb
|
94
|
+
- lib/akephalos.rb
|
95
|
+
- src/htmlunit/commons-codec-1.4.jar
|
96
|
+
- src/htmlunit/commons-collections-3.2.1.jar
|
97
|
+
- src/htmlunit/commons-httpclient-3.1.jar
|
98
|
+
- src/htmlunit/commons-io-1.4.jar
|
99
|
+
- src/htmlunit/commons-lang-2.4.jar
|
100
|
+
- src/htmlunit/commons-logging-1.1.1.jar
|
101
|
+
- src/htmlunit/cssparser-0.9.5.jar
|
102
|
+
- src/htmlunit/htmlunit-2.7.jar
|
103
|
+
- src/htmlunit/htmlunit-core-js-2.7.jar
|
104
|
+
- src/htmlunit/nekohtml-1.9.14.jar
|
105
|
+
- src/htmlunit/sac-1.3.jar
|
106
|
+
- src/htmlunit/serializer-2.7.1.jar
|
107
|
+
- src/htmlunit/xalan-2.7.1.jar
|
108
|
+
- src/htmlunit/xercesImpl-2.9.1.jar
|
109
|
+
- src/htmlunit/xml-apis-1.3.04.jar
|
110
|
+
- README.md
|
111
|
+
- MIT_LICENSE
|
112
112
|
has_rdoc: true
|
113
|
-
homepage: http://github.com/
|
113
|
+
homepage: http://bernerdschaefer.github.com/akephalos
|
114
114
|
licenses: []
|
115
115
|
|
116
116
|
post_install_message:
|
117
|
-
rdoc_options:
|
118
|
-
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
119
|
require_paths:
|
120
|
-
- lib
|
120
|
+
- - lib
|
121
|
+
- src
|
121
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
123
|
requirements:
|
123
124
|
- - ">="
|
@@ -130,18 +131,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
- - ">="
|
131
132
|
- !ruby/object:Gem::Version
|
132
133
|
segments:
|
133
|
-
-
|
134
|
-
|
134
|
+
- 1
|
135
|
+
- 3
|
136
|
+
- 6
|
137
|
+
version: 1.3.6
|
135
138
|
requirements: []
|
136
139
|
|
137
|
-
rubyforge_project:
|
140
|
+
rubyforge_project: akephalos
|
138
141
|
rubygems_version: 1.3.6
|
139
142
|
signing_key:
|
140
143
|
specification_version: 3
|
141
|
-
summary:
|
142
|
-
test_files:
|
143
|
-
|
144
|
-
- spec/filter_spec.rb
|
145
|
-
- spec/session/akephalos_session_spec.rb
|
146
|
-
- spec/slow_page_loads_spec.rb
|
147
|
-
- spec/spec_helper.rb
|
144
|
+
summary: Headless Browser for Integration Testing with Capybara
|
145
|
+
test_files: []
|
146
|
+
|
data/.gitignore
DELETED
data/README
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Akephalos is an interface for HTMLUnit, exposing it's headless browsing power
|
2
|
-
to Capybara. The only assumption made is that you are using Capybara and have
|
3
|
-
a java runtime available.
|
4
|
-
|
5
|
-
When running tests with ruby (1.8.7, 1.9.1), akephalos will expose its client
|
6
|
-
over DRb from a java server. When running with jruby the client will be
|
7
|
-
embedded in process.
|
8
|
-
|
9
|
-
Setup
|
10
|
-
=====
|
11
|
-
|
12
|
-
Using akephalos is as simple as requiring it and setting Capybara's javascript
|
13
|
-
driver:
|
14
|
-
|
15
|
-
require 'akephalos'
|
16
|
-
Capybara.default_javascript_driver = :akephalos
|
17
|
-
|
18
|
-
Running for Cucumber
|
19
|
-
====================
|
20
|
-
|
21
|
-
When akephalos is required from a cucumber environment, it will only run for
|
22
|
-
features tagged with @akephalos. Set Capybara's default_javascript_driver to
|
23
|
-
also use akephalos for features tagged as @javascript.
|
data/Rakefile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "akephalos"
|
8
|
-
gem.summary = ""
|
9
|
-
gem.description = ""
|
10
|
-
gem.email = "bj.schaefer@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/bernerdschaefer/akephalos"
|
12
|
-
gem.authors = ["Bernerd Schaefer"]
|
13
|
-
|
14
|
-
gem.add_dependency "capybara", '0.3.8'
|
15
|
-
|
16
|
-
gem.add_development_dependency "sinatra"
|
17
|
-
gem.add_development_dependency "rspec", '1.3.0'
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'spec/rake/spectask'
|
24
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
-
spec.libs << 'lib' << 'spec'
|
26
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
-
end
|
28
|
-
|
29
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
-
spec.libs << 'lib' << 'spec'
|
31
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
-
spec.rcov = true
|
33
|
-
end
|
34
|
-
|
35
|
-
task :spec => :check_dependencies
|
36
|
-
|
37
|
-
task :default => :spec
|
data/TODO.txt
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
0.0.5
|
2
|
-
=======================================================================================
|
3
|
-
* Upgrade to htmlunit-2.7
|
4
|
-
* Fix DRb recycled object errors
|
5
|
-
* Define NativeException on ruby side so that uncaught exceptions are displayed with
|
6
|
-
a proper backtrace.
|
7
|
-
* Add Akephalos.filter() for enabling FakeWeb style request/response mocking in the
|
8
|
-
HtmlUnit browser.
|
9
|
-
|
10
|
-
0.0.4
|
11
|
-
=======================================================================================
|
12
|
-
- Update to jruby 1.5
|
13
|
-
- bin/akephalos for interactive mode
|
14
|
-
- use internally managed java threading instead of capybara's own wait methods
|
15
|
-
|
16
|
-
0.0.3
|
17
|
-
=======================================================================================
|
18
|
-
|
19
|
-
- Update for compatibility with capybara 0.3.8
|
20
|
-
|
21
|
-
0.0.2 - 10 May 2010
|
22
|
-
=======================================================================================
|
23
|
-
|
24
|
-
- Ensure users cannot accidently call non-existant methods on DRb objects
|
25
|
-
- Refactor akephalos classes to expose HTMLUnit behavior, instead of shipping
|
26
|
-
objects directly to remote process.
|
27
|
-
|
28
|
-
|
29
|
-
0.0.1 - 03 May 2010
|
30
|
-
=======================================================================================
|
31
|
-
- DRb server starts automatically when needed
|
32
|
-
- DRb objects are undumped, and references are kept on the server
|
33
|
-
- All capybara provided specs pass.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.5
|
data/akephalos.gemspec
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{akephalos}
|
8
|
-
s.version = "0.0.5"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Bernerd Schaefer"]
|
12
|
-
s.date = %q{2010-06-24}
|
13
|
-
s.default_executable = %q{akephalos}
|
14
|
-
s.description = %q{}
|
15
|
-
s.email = %q{bj.schaefer@gmail.com}
|
16
|
-
s.executables = ["akephalos"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"README"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".gitignore",
|
22
|
-
"README",
|
23
|
-
"Rakefile",
|
24
|
-
"TODO.txt",
|
25
|
-
"VERSION",
|
26
|
-
"akephalos.gemspec",
|
27
|
-
"bin/akephalos",
|
28
|
-
"lib/akephalos.rb",
|
29
|
-
"lib/akephalos/capybara.rb",
|
30
|
-
"lib/akephalos/client.rb",
|
31
|
-
"lib/akephalos/client/filter.rb",
|
32
|
-
"lib/akephalos/client/listener.rb",
|
33
|
-
"lib/akephalos/configuration.rb",
|
34
|
-
"lib/akephalos/console.rb",
|
35
|
-
"lib/akephalos/cucumber.rb",
|
36
|
-
"lib/akephalos/htmlunit.rb",
|
37
|
-
"lib/akephalos/htmlunit/ext/http_method.rb",
|
38
|
-
"lib/akephalos/node.rb",
|
39
|
-
"lib/akephalos/page.rb",
|
40
|
-
"lib/akephalos/remote_client.rb",
|
41
|
-
"lib/akephalos/server.rb",
|
42
|
-
"spec/driver/akephalos_driver_spec.rb",
|
43
|
-
"spec/filter_spec.rb",
|
44
|
-
"spec/session/akephalos_session_spec.rb",
|
45
|
-
"spec/slow_page_loads_spec.rb",
|
46
|
-
"spec/spec.opts",
|
47
|
-
"spec/spec_helper.rb",
|
48
|
-
"src/commons-codec-1.4.jar",
|
49
|
-
"src/commons-collections-3.2.1.jar",
|
50
|
-
"src/commons-httpclient-3.1.jar",
|
51
|
-
"src/commons-io-1.4.jar",
|
52
|
-
"src/commons-lang-2.4.jar",
|
53
|
-
"src/commons-logging-1.1.1.jar",
|
54
|
-
"src/cssparser-0.9.5.jar",
|
55
|
-
"src/htmlunit-2.7.jar",
|
56
|
-
"src/htmlunit-core-js-2.7.jar",
|
57
|
-
"src/jruby-complete-1.5.0.jar",
|
58
|
-
"src/nekohtml-1.9.14.jar",
|
59
|
-
"src/sac-1.3.jar",
|
60
|
-
"src/serializer-2.7.1.jar",
|
61
|
-
"src/xalan-2.7.1.jar",
|
62
|
-
"src/xercesImpl-2.9.1.jar",
|
63
|
-
"src/xml-apis-1.3.04.jar"
|
64
|
-
]
|
65
|
-
s.homepage = %q{http://github.com/bernerdschaefer/akephalos}
|
66
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
67
|
-
s.require_paths = ["lib"]
|
68
|
-
s.rubygems_version = %q{1.3.6}
|
69
|
-
s.summary = %q{}
|
70
|
-
s.test_files = [
|
71
|
-
"spec/driver/akephalos_driver_spec.rb",
|
72
|
-
"spec/filter_spec.rb",
|
73
|
-
"spec/session/akephalos_session_spec.rb",
|
74
|
-
"spec/slow_page_loads_spec.rb",
|
75
|
-
"spec/spec_helper.rb"
|
76
|
-
]
|
77
|
-
|
78
|
-
if s.respond_to? :specification_version then
|
79
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
80
|
-
s.specification_version = 3
|
81
|
-
|
82
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
83
|
-
s.add_runtime_dependency(%q<capybara>, ["= 0.3.8"])
|
84
|
-
s.add_development_dependency(%q<sinatra>, [">= 0"])
|
85
|
-
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
86
|
-
else
|
87
|
-
s.add_dependency(%q<capybara>, ["= 0.3.8"])
|
88
|
-
s.add_dependency(%q<sinatra>, [">= 0"])
|
89
|
-
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
90
|
-
end
|
91
|
-
else
|
92
|
-
s.add_dependency(%q<capybara>, ["= 0.3.8"])
|
93
|
-
s.add_dependency(%q<sinatra>, [">= 0"])
|
94
|
-
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
data/spec/filter_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Filters" do
|
4
|
-
before do
|
5
|
-
@session = Capybara::Session.new(:akephalos, TestApp)
|
6
|
-
end
|
7
|
-
|
8
|
-
context "with no filter" do
|
9
|
-
it "returns the page's source" do
|
10
|
-
@session.visit "/"
|
11
|
-
@session.source.should == "Hello world!"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with a filter" do
|
16
|
-
after { Akephalos.filters.clear }
|
17
|
-
|
18
|
-
it "returns the filter's source" do
|
19
|
-
Akephalos.filter :get, %r{.*}, :body => "Howdy!"
|
20
|
-
@session.visit "/"
|
21
|
-
@session.source.should == "Howdy!"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Capybara::Session do
|
4
|
-
context 'with akephalos driver' do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@session = Capybara::Session.new(:akephalos, TestApp)
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#driver' do
|
11
|
-
it "should be a headless driver" do
|
12
|
-
@session.driver.should be_an_instance_of(Capybara::Driver::Akephalos)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#mode' do
|
17
|
-
it "should remember the mode" do
|
18
|
-
@session.mode.should == :akephalos
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it_should_behave_like "session"
|
23
|
-
it_should_behave_like "session with javascript support"
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class SlowApp < TestApp
|
4
|
-
get '/slow_page' do
|
5
|
-
sleep 1
|
6
|
-
"<p>Loaded!</p>"
|
7
|
-
end
|
8
|
-
|
9
|
-
get '/really_slow_page' do
|
10
|
-
sleep 5
|
11
|
-
end
|
12
|
-
|
13
|
-
get '/slow_ajax_load' do
|
14
|
-
<<-HTML
|
15
|
-
<head>
|
16
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
17
|
-
<title>with_js</title>
|
18
|
-
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
19
|
-
<script type="text/javascript">
|
20
|
-
$(function() {
|
21
|
-
$('#ajax_load').click(function() {
|
22
|
-
// $('body').html("<p>Loaded!</p>");
|
23
|
-
$('body').load('/slow_page');
|
24
|
-
return false;
|
25
|
-
});
|
26
|
-
});
|
27
|
-
</script>
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<a href="#" id="ajax_load">Click me</a>
|
31
|
-
</body>
|
32
|
-
HTML
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
if $0 == __FILE__
|
37
|
-
if __FILE__ == $0
|
38
|
-
Rack::Handler::Mongrel.run SlowApp, :Port => 8070
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe Capybara::Session do
|
43
|
-
context 'with akephalos driver' do
|
44
|
-
|
45
|
-
before do
|
46
|
-
@session = Capybara::Session.new(:akephalos, SlowApp)
|
47
|
-
end
|
48
|
-
|
49
|
-
context "slow page load" do
|
50
|
-
it "should wait for the page to finish loading" do
|
51
|
-
@session.visit('/slow_page')
|
52
|
-
@session.current_url.should include('/slow_page')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "slow ajax load" do
|
57
|
-
it "should wait for ajax to load" do
|
58
|
-
@session.visit('/slow_ajax_load')
|
59
|
-
@session.click_link('Click me')
|
60
|
-
@session.should have_xpath("//p[contains(.,'Loaded!')]")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
data/spec/spec.opts
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'akephalos'
|
3
|
-
|
4
|
-
spec_dir = nil
|
5
|
-
$:.detect do |dir|
|
6
|
-
if File.exists? File.join(dir, "capybara.rb")
|
7
|
-
spec_dir = File.expand_path(File.join(dir,"..","spec"))
|
8
|
-
$:.unshift( spec_dir )
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
require File.join(spec_dir,"spec_helper")
|
Binary file
|