culerity 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/culerity/celerity_server.rb +14 -1
- data/lib/culerity/persistent_delivery.rb +7 -8
- data/lib/culerity/remote_browser_proxy.rb +12 -8
- data/lib/culerity/remote_object_proxy.rb +10 -2
- data/spec/celerity_server_spec.rb +12 -0
- data/spec/remote_browser_proxy_spec.rb +2 -2
- data/spec/remote_object_proxy_spec.rb +22 -1
- metadata +15 -7
- data/.gitignore +0 -6
data/VERSION.yml
CHANGED
@@ -20,7 +20,7 @@ module Culerity
|
|
20
20
|
result = target(call.first).send call[1], *call[2..-1], &block
|
21
21
|
_out << "[:return, #{proxify result}]\n"
|
22
22
|
rescue => e
|
23
|
-
_out << "[:exception, \"#{e.class.name}\", #{e.message.inspect}, #{e.
|
23
|
+
_out << "[:exception, \"#{e.class.name}\", #{e.message.inspect}, #{prepend_js_stack_trace(e).inspect}]\n"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -77,5 +77,18 @@ module Culerity
|
|
77
77
|
"Culerity::RemoteObjectProxy.new(#{result.object_id}, @io)"
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
def prepend_js_stack_trace(exception)
|
82
|
+
def extract_js_strack_trace(e)
|
83
|
+
if e.respond_to?(:getScriptStackTrace)
|
84
|
+
e.getScriptStackTrace
|
85
|
+
elsif e.respond_to?(:cause) && e.cause
|
86
|
+
extract_js_strack_trace e.cause
|
87
|
+
else
|
88
|
+
""
|
89
|
+
end
|
90
|
+
end
|
91
|
+
extract_js_strack_trace(exception).split("\n") + exception.backtrace
|
92
|
+
end
|
80
93
|
end
|
81
94
|
end
|
@@ -2,10 +2,10 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Culerity
|
4
4
|
module PersistentDelivery
|
5
|
-
|
5
|
+
|
6
6
|
DELIVERIES_PATH =
|
7
7
|
File.join(RAILS_ROOT, 'tmp', 'action_mailer_acceptance_deliveries.cache')
|
8
|
-
|
8
|
+
|
9
9
|
def self.included(base)
|
10
10
|
base.class_eval do
|
11
11
|
def self.deliveries
|
@@ -20,14 +20,13 @@ module Culerity
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def perform_delivery_persistent(mail)
|
25
|
-
deliveries << mail
|
26
|
-
File.open(DELIVERIES_PATH,'w') do |f|
|
25
|
+
deliveries = self.class.deliveries << mail
|
26
|
+
File.open(DELIVERIES_PATH,'w') do |f|
|
27
27
|
f << Marshal.dump(deliveries)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
28
|
+
end
|
29
|
+
end
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
@@ -13,13 +13,15 @@ module Culerity
|
|
13
13
|
# +time_to_wait+ is 30 seconds by default
|
14
14
|
#
|
15
15
|
# Returns true upon success
|
16
|
-
# Raises
|
16
|
+
# Raises RuntimeError when +time_to_wait+ is reached.
|
17
17
|
#
|
18
18
|
def wait_until time_to_wait=30, &block
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
time_limit = Time.now + time_to_wait
|
20
|
+
until block.call
|
21
|
+
if Time.now > time_limit
|
22
|
+
raise "wait_until timeout after #{time_to_wait} seconds"
|
22
23
|
end
|
24
|
+
sleep 0.1
|
23
25
|
end
|
24
26
|
true
|
25
27
|
end
|
@@ -29,13 +31,15 @@ module Culerity
|
|
29
31
|
# +time_to_wait+ is 30 seconds by default
|
30
32
|
#
|
31
33
|
# Returns true upon success
|
32
|
-
# Raises
|
34
|
+
# Raises RuntimeError when +time_to_wait+ is reached.
|
33
35
|
#
|
34
36
|
def wait_while time_to_wait=30, &block
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
time_limit = Time.now + time_to_wait
|
38
|
+
while block.call
|
39
|
+
if Time.now > time_limit
|
40
|
+
raise "wait_while timeout after #{time_to_wait} seconds"
|
38
41
|
end
|
42
|
+
sleep 0.1
|
39
43
|
end
|
40
44
|
true
|
41
45
|
end
|
@@ -20,7 +20,11 @@ module Culerity
|
|
20
20
|
def id
|
21
21
|
send_remote(:id)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
|
+
def inspect
|
25
|
+
send_remote(:inspect)
|
26
|
+
end
|
27
|
+
|
24
28
|
def method_missing(name, *args, &block)
|
25
29
|
send_remote(name, *args, &block)
|
26
30
|
end
|
@@ -51,7 +55,11 @@ module Culerity
|
|
51
55
|
if res.first == :return
|
52
56
|
res[1]
|
53
57
|
elsif res.first == :exception
|
54
|
-
|
58
|
+
begin
|
59
|
+
raise "local trace"
|
60
|
+
rescue => ex
|
61
|
+
raise CulerityException.new("#{res[1]}: #{res[2]}", res[3] + ex.backtrace)
|
62
|
+
end
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
@@ -133,4 +133,16 @@ describe Culerity::CelerityServer do
|
|
133
133
|
_out.should_receive(:<<).with(/^\[:exception, \"RuntimeError\", \"test exception with \\\"quotes\\\"\", \[.*\]\]\n$/)
|
134
134
|
Culerity::CelerityServer.new(_in, _out)
|
135
135
|
end
|
136
|
+
|
137
|
+
it "should extract a js stack trace if available and prepend it on the regular backtrace" do
|
138
|
+
exception = RuntimeError.new("the exception")
|
139
|
+
exception.stub!(:cause => stub('ex2', :cause => stub('ex3', :getScriptStackTrace => "The\nStack\nTrace")))
|
140
|
+
|
141
|
+
@browser.stub!(:goto).and_raise(exception)
|
142
|
+
_in = stub 'in'
|
143
|
+
_in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
|
144
|
+
_out = stub 'out'
|
145
|
+
_out.should_receive(:<<).with(/^\[:exception, \"RuntimeError\", \"the exception\", \[\"The\", \"Stack\", \"Trace\", \".*\"\]\]\n$/)
|
146
|
+
Culerity::CelerityServer.new(_in, _out)
|
147
|
+
end
|
136
148
|
end
|
@@ -28,7 +28,7 @@ describe Culerity::RemoteBrowserProxy do
|
|
28
28
|
proxy = Culerity::RemoteBrowserProxy.new @io
|
29
29
|
lambda {
|
30
30
|
proxy.wait_until(0.1) { false }
|
31
|
-
}.should raise_error(
|
31
|
+
}.should raise_error(RuntimeError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return successfully when wait_until returns true" do
|
@@ -40,7 +40,7 @@ describe Culerity::RemoteBrowserProxy do
|
|
40
40
|
proxy = Culerity::RemoteBrowserProxy.new @io
|
41
41
|
lambda {
|
42
42
|
proxy.wait_while(0.1) { true }
|
43
|
-
}.should raise_error(
|
43
|
+
}.should raise_error(RuntimeError)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should return successfully when wait_while returns !true" do
|
@@ -41,6 +41,13 @@ describe Culerity::RemoteObjectProxy do
|
|
41
41
|
proxy = Culerity::RemoteObjectProxy.new 345, io
|
42
42
|
proxy.goto '/homepage'
|
43
43
|
end
|
44
|
+
|
45
|
+
it "should send inspect as a serialized method call to the output" do
|
46
|
+
io = stub 'io', :gets => '[:return, "inspect output"]'
|
47
|
+
io.should_receive(:<<).with(%Q{[[345, "inspect"]]\n})
|
48
|
+
proxy = Culerity::RemoteObjectProxy.new 345, io
|
49
|
+
proxy.inspect.should == "inspect output"
|
50
|
+
end
|
44
51
|
|
45
52
|
it "should send the serialized method call with a proc argument to the output" do
|
46
53
|
io = stub 'io', :gets => "[:return]"
|
@@ -57,7 +64,7 @@ describe Culerity::RemoteObjectProxy do
|
|
57
64
|
|
58
65
|
proxy.send_remote(:method) { "lambda { true }" }
|
59
66
|
end
|
60
|
-
|
67
|
+
|
61
68
|
it "should return the deserialized return value" do
|
62
69
|
io = stub 'io', :gets => "[:return, :okay]\n", :<< => nil
|
63
70
|
proxy = Culerity::RemoteObjectProxy.new 345, io
|
@@ -72,6 +79,20 @@ describe Culerity::RemoteObjectProxy do
|
|
72
79
|
}.should raise_error(Culerity::CulerityException)
|
73
80
|
end
|
74
81
|
|
82
|
+
it "should include the full 'local' back trace in addition to the 'remote' backtrace" do
|
83
|
+
io = stub 'io', :gets => %Q{[:exception, "RuntimeError", "test exception", ["Remote", "Backtrace"]]}, :<< => nil
|
84
|
+
proxy = Culerity::RemoteObjectProxy.new 345, io
|
85
|
+
begin
|
86
|
+
proxy.goto '/home'
|
87
|
+
rescue => ex
|
88
|
+
puts ex.backtrace
|
89
|
+
ex.backtrace[0].should == "Remote"
|
90
|
+
ex.backtrace[1].should == "Backtrace"
|
91
|
+
ex.backtrace.detect {|line| line =~ /lib\/culerity\/remote_object_proxy\.rb/}.should_not be_nil
|
92
|
+
ex.backtrace.detect {|line| line =~ /spec\/remote_object_proxy_spec\.rb/}.should_not be_nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
75
96
|
it "should send exit" do
|
76
97
|
io = stub 'io', :gets => '[:return]'
|
77
98
|
io.should_receive(:<<).with('["_exit_"]')
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: culerity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 13
|
10
|
+
version: 0.2.13
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Alexander Lang
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-12-19 00:00:00 +01:00
|
18
19
|
default_executable: run_celerity_server.rb
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: cucumber
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: rspec
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -50,7 +55,6 @@ extensions: []
|
|
50
55
|
extra_rdoc_files:
|
51
56
|
- README.md
|
52
57
|
files:
|
53
|
-
- .gitignore
|
54
58
|
- CHANGES.md
|
55
59
|
- MIT-LICENSE
|
56
60
|
- README.md
|
@@ -98,28 +102,32 @@ homepage: http://github.com/langalex/culerity
|
|
98
102
|
licenses: []
|
99
103
|
|
100
104
|
post_install_message:
|
101
|
-
rdoc_options:
|
102
|
-
|
105
|
+
rdoc_options: []
|
106
|
+
|
103
107
|
require_paths:
|
104
108
|
- lib
|
105
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
106
111
|
requirements:
|
107
112
|
- - ">="
|
108
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
109
115
|
segments:
|
110
116
|
- 0
|
111
117
|
version: "0"
|
112
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
113
120
|
requirements:
|
114
121
|
- - ">="
|
115
122
|
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
116
124
|
segments:
|
117
125
|
- 0
|
118
126
|
version: "0"
|
119
127
|
requirements: []
|
120
128
|
|
121
129
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.3.
|
130
|
+
rubygems_version: 1.3.7
|
123
131
|
signing_key:
|
124
132
|
specification_version: 3
|
125
133
|
summary: Culerity integrates Cucumber and Celerity in order to test your application's full stack.
|