akephalos2 2.1.2-java → 2.1.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/akephalos/client.rb +11 -0
- data/lib/akephalos/exception_handling_delegators.rb +66 -0
- data/lib/akephalos/node.rb +11 -0
- data/lib/akephalos/page.rb +11 -0
- data/lib/akephalos/remote_client.rb +0 -4
- data/lib/akephalos/version.rb +1 -1
- metadata +34 -12
data/lib/akephalos/client.rb
CHANGED
@@ -8,6 +8,7 @@ else
|
|
8
8
|
require 'akephalos/htmlunit/ext/http_method'
|
9
9
|
require 'akephalos/htmlunit/ext/confirm_handler'
|
10
10
|
|
11
|
+
require 'akephalos/exception_handling_delegators'
|
11
12
|
require 'akephalos/page'
|
12
13
|
require 'akephalos/node'
|
13
14
|
|
@@ -21,6 +22,16 @@ else
|
|
21
22
|
# allowing navigation.
|
22
23
|
class Client
|
23
24
|
|
25
|
+
class << self
|
26
|
+
|
27
|
+
alias_method :new_orig, :new
|
28
|
+
|
29
|
+
def new(*args)
|
30
|
+
ExceptionConvertingDelegator.new(new_orig(*args), "NativeException", RuntimeError)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
24
35
|
# @return [Akephalos::Page] the current page
|
25
36
|
attr_reader :page
|
26
37
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
##
|
4
|
+
# This class can be used to wrap an object so that any exceptions raised by the object's methods are recued and passed to a specified exception_handler block
|
5
|
+
#
|
6
|
+
class ExceptionCatchingDelegator < SimpleDelegator
|
7
|
+
|
8
|
+
##
|
9
|
+
# * *Args* :
|
10
|
+
# - ++ -> delgate - object to be wrapped
|
11
|
+
# - ++ -> exception_handler - block to handle rescued exeptions (will be called with yield(exception))
|
12
|
+
#
|
13
|
+
def initialize(delegate, exception_handler)
|
14
|
+
super(delegate)
|
15
|
+
@exception_handler = exception_handler
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Override of method_missing to rescue exceptions and pass them to the exception_handler
|
20
|
+
#
|
21
|
+
def method_missing(m, *args, &block)
|
22
|
+
begin
|
23
|
+
return super(m, *args, &block)
|
24
|
+
rescue Exception => exception
|
25
|
+
@exception_handler.yield(exception)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# This class can be used to wrap an object so that exceptions matching a given type are rescued and then raised as another type.
|
33
|
+
#
|
34
|
+
# This kind of exception converting is most of use when dealing with exceptions passed across DRb where a remote
|
35
|
+
# exception class may not exist on the client-side.
|
36
|
+
#
|
37
|
+
class ExceptionConvertingDelegator < ExceptionCatchingDelegator
|
38
|
+
|
39
|
+
##
|
40
|
+
# * *Args* :
|
41
|
+
# - ++ -> delgate - object to be wrapped
|
42
|
+
# - ++ -> exception_type_to_catch - an exception class or name of an exception class that will be used to match (in a regular-expression sense) the name of exceptions thrown by the delegate's methods
|
43
|
+
# - ++ -> exception_type_to_throw - the exception class that will be used to create and raise a new exception
|
44
|
+
#
|
45
|
+
def initialize(delegate, exception_type_to_catch = Exception, exception_type_to_throw = RuntimeError)
|
46
|
+
|
47
|
+
handler = lambda do |e|
|
48
|
+
|
49
|
+
raise e unless e.class.name =~ Regexp.new(exception_type_to_catch.to_s)
|
50
|
+
|
51
|
+
# Create and raise a RuntimeError
|
52
|
+
message = e.class.name
|
53
|
+
unless e.message.nil? || e.message.size == 0
|
54
|
+
message << " "
|
55
|
+
message << e.message
|
56
|
+
end
|
57
|
+
new_exception = exception_type_to_throw.new(message)
|
58
|
+
new_exception.set_backtrace(e.backtrace)
|
59
|
+
raise new_exception
|
60
|
+
end
|
61
|
+
|
62
|
+
super(delegate, handler)
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/lib/akephalos/node.rb
CHANGED
@@ -3,6 +3,17 @@ module Akephalos
|
|
3
3
|
# Akephalos::Node wraps HtmlUnit's DOMNode class, providing a simple API for
|
4
4
|
# interacting with an element on the page.
|
5
5
|
class Node
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
alias_method :new_orig, :new
|
10
|
+
|
11
|
+
def new(*args)
|
12
|
+
ExceptionConvertingDelegator.new(new_orig(*args), "NativeException", RuntimeError)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
6
17
|
# @param [HtmlUnit::DOMNode] node
|
7
18
|
def initialize(node)
|
8
19
|
@nodes = []
|
data/lib/akephalos/page.rb
CHANGED
@@ -3,6 +3,17 @@ module Akephalos
|
|
3
3
|
# Akephalos::Page wraps HtmlUnit's HtmlPage class, exposing an API for
|
4
4
|
# interacting with a page in the browser.
|
5
5
|
class Page
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
alias_method :new_orig, :new
|
10
|
+
|
11
|
+
def new(*args)
|
12
|
+
ExceptionConvertingDelegator.new(new_orig(*args), "NativeException", RuntimeError)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
6
17
|
# @param [HtmlUnit::HtmlPage] page
|
7
18
|
def initialize(page)
|
8
19
|
@nodes = []
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'drb/drb'
|
3
3
|
|
4
|
-
# We need to define our own NativeException class for the cases when a native
|
5
|
-
# exception is raised by the JRuby DRb server.
|
6
|
-
class NativeException < StandardError; end
|
7
|
-
|
8
4
|
module Akephalos
|
9
5
|
|
10
6
|
# The +RemoteClient+ class provides an interface to an +Akephalos::Client+
|
data/lib/akephalos/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akephalos2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-04-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: capybara
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: rake
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -33,10 +38,15 @@ dependencies:
|
|
33
38
|
version: '0'
|
34
39
|
type: :runtime
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: sinatra
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ! '>='
|
@@ -44,10 +54,15 @@ dependencies:
|
|
44
54
|
version: '0'
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
48
63
|
- !ruby/object:Gem::Dependency
|
49
64
|
name: rspec
|
50
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
51
66
|
none: false
|
52
67
|
requirements:
|
53
68
|
- - ! '>='
|
@@ -55,7 +70,12 @@ dependencies:
|
|
55
70
|
version: '0'
|
56
71
|
type: :development
|
57
72
|
prerelease: false
|
58
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
59
79
|
description: Headless Browser for Integration Testing with Capybara
|
60
80
|
email:
|
61
81
|
- bj.schaefer@gmail.com
|
@@ -72,6 +92,7 @@ files:
|
|
72
92
|
- lib/akephalos/configuration.rb
|
73
93
|
- lib/akephalos/console.rb
|
74
94
|
- lib/akephalos/cucumber.rb
|
95
|
+
- lib/akephalos/exception_handling_delegators.rb
|
75
96
|
- lib/akephalos/htmlunit/ext/confirm_handler.rb
|
76
97
|
- lib/akephalos/htmlunit/ext/http_method.rb
|
77
98
|
- lib/akephalos/htmlunit.rb
|
@@ -84,7 +105,8 @@ files:
|
|
84
105
|
- lib/akephalos.rb
|
85
106
|
- README.md
|
86
107
|
- MIT_LICENSE
|
87
|
-
-
|
108
|
+
- !binary |-
|
109
|
+
YmluL2FrZXBoYWxvcw==
|
88
110
|
homepage: https://github.com/Nerian/akephalos2
|
89
111
|
licenses: []
|
90
112
|
post_install_message:
|
@@ -106,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
128
|
version: '0'
|
107
129
|
requirements: []
|
108
130
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.21
|
110
132
|
signing_key:
|
111
133
|
specification_version: 3
|
112
134
|
summary: Headless Browser for Integration Testing with Capybara
|