screw-unit 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -1
- data/core/CHANGES +10 -0
- data/core/example/models/man.js +2 -2
- data/core/lib/jquery.print.js +2 -2
- data/core/lib/screw.behaviors.js +3 -2
- data/core/lib/screw.builder.js +15 -15
- data/core/lib/screw.css +2 -2
- data/core/lib/screw.events.js +3 -2
- data/core/lib/screw.matchers.js +53 -11
- data/core/spec/behaviors_spec.js +11 -1
- data/core/spec/matchers_spec.js +144 -9
- data/core/spec/print_spec.js +14 -8
- data/lib/screw_unit/resources/spec.rb +66 -3
- data/spec/functional/functional_spec_helper.rb +1 -1
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +7 -8
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +5 -6
- data/spec/unit/unit_spec_helper.rb +1 -3
- data/vendor/js-test-core/CHANGES +5 -0
- data/vendor/js-test-core/Rakefile +1 -1
- data/vendor/js-test-core/lib/js_test_core/client.rb +19 -16
- data/vendor/js-test-core/lib/js_test_core/resources.rb +2 -2
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +9 -18
- data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +17 -15
- data/vendor/js-test-core/lib/js_test_core/resources/{suite.rb → session.rb} +8 -4
- data/vendor/js-test-core/lib/js_test_core/resources/{suite_finish.rb → session_finish.rb} +5 -5
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +6 -3
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +22 -21
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +0 -38
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +83 -63
- data/vendor/js-test-core/spec/unit/js_test_core/resources/{suite_finish_spec.rb → session_finish_spec.rb} +15 -18
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +82 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +3 -3
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +37 -10
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource.rb +4 -0
- metadata +88 -89
- data/core/lib/screw.assets.js +0 -36
- data/core/lib/screw.server.js +0 -21
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -86
@@ -1,9 +1,9 @@
|
|
1
1
|
module JsTestCore
|
2
2
|
module Resources
|
3
|
-
class
|
3
|
+
class Session < ThinRest::Resource
|
4
4
|
class Collection < ThinRest::Resource
|
5
5
|
route ANY do |env, id|
|
6
|
-
|
6
|
+
Session.new(env.merge(:id => id))
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -23,7 +23,7 @@ module JsTestCore
|
|
23
23
|
if runner.successful?
|
24
24
|
connection.send_body("status=#{SUCCESSFUL_COMPLETION}")
|
25
25
|
else
|
26
|
-
connection.send_body("status=#{FAILURE_COMPLETION}&reason=#{runner.
|
26
|
+
connection.send_body("status=#{FAILURE_COMPLETION}&reason=#{runner.session_run_result}")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
else
|
@@ -33,7 +33,11 @@ module JsTestCore
|
|
33
33
|
end
|
34
34
|
|
35
35
|
route 'finish' do |env, name|
|
36
|
-
|
36
|
+
SessionFinish.new(env.merge(:session => self))
|
37
|
+
end
|
38
|
+
|
39
|
+
def associated_with_a_runner?
|
40
|
+
id.to_s != ""
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module JsTestCore
|
2
2
|
module Resources
|
3
|
-
class
|
4
|
-
property :
|
3
|
+
class SessionFinish < ThinRest::Resource
|
4
|
+
property :session
|
5
5
|
|
6
6
|
def post
|
7
|
-
if
|
8
|
-
|
7
|
+
if session.associated_with_a_runner?
|
8
|
+
Runner.finalize(session.id, rack_request['text'])
|
9
9
|
else
|
10
|
-
|
10
|
+
STDOUT.puts rack_request['text']
|
11
11
|
end
|
12
12
|
connection.send_head
|
13
13
|
connection.send_body("")
|
@@ -16,7 +16,10 @@ module JsTestCore
|
|
16
16
|
:relative_path => "/implementations"
|
17
17
|
))
|
18
18
|
end
|
19
|
-
route "
|
19
|
+
route "sessions", "JsTestCore::Resources::Session::Collection"
|
20
|
+
route "session" do |env, name|
|
21
|
+
Session.new(env.merge(:id => rack_request.cookies["session_id"]))
|
22
|
+
end
|
20
23
|
route "runners", "JsTestCore::Resources::Runner::Collection"
|
21
24
|
route "specs" do |env, name|
|
22
25
|
if self.class.dispatch_strategy == :specs
|
@@ -55,8 +58,8 @@ module JsTestCore
|
|
55
58
|
property :public_path
|
56
59
|
|
57
60
|
def get
|
58
|
-
connection.send_head(
|
59
|
-
connection.send_body("<
|
61
|
+
connection.send_head(200, :Location => "/#{self.class.dispatch_strategy}")
|
62
|
+
connection.send_body("<html><head></head><body>Welcome to the Js Test Server. Click the following link to run you <a href=/specs>spec suite</a>.</body></html>")
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
@@ -9,19 +9,20 @@ module JsTestCore
|
|
9
9
|
Client.const_set(:STDOUT, stdout)
|
10
10
|
@request = "http request"
|
11
11
|
mock(Net::HTTP).start(DEFAULT_HOST, DEFAULT_PORT).yields(request)
|
12
|
+
stub.instance_of(Client).sleep
|
12
13
|
end
|
13
14
|
|
14
15
|
after do
|
15
16
|
Client.__send__(:remove_const, :STDOUT)
|
16
17
|
end
|
17
18
|
|
18
|
-
it "tells the server to start a
|
19
|
+
it "tells the server to start a session run in Firefox and polls the status of the session until the session is complete" do
|
19
20
|
mock_post_to_runner("*firefox")
|
20
21
|
mock_polling_returns([running_status, running_status, success_status])
|
21
22
|
Client.run
|
22
23
|
end
|
23
24
|
|
24
|
-
context "when the
|
25
|
+
context "when the Session run ends in 'success'" do
|
25
26
|
before do
|
26
27
|
mock_post_to_runner("*firefox")
|
27
28
|
mock_polling_returns([running_status, running_status, success_status])
|
@@ -37,7 +38,7 @@ module JsTestCore
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
context "when the
|
41
|
+
context "when the Session run ends in 'failure'" do
|
41
42
|
attr_reader :failure_reason
|
42
43
|
before do
|
43
44
|
mock_post_to_runner("*firefox")
|
@@ -58,18 +59,18 @@ module JsTestCore
|
|
58
59
|
it "reports the reason for failure"
|
59
60
|
end
|
60
61
|
|
61
|
-
context "when the
|
62
|
-
it "raises a
|
62
|
+
context "when the Session is not found" do
|
63
|
+
it "raises a SessionNotFound error" do
|
63
64
|
mock_post_to_runner("*firefox")
|
64
|
-
mock(request).get("/
|
65
|
-
stub(
|
66
|
-
|
65
|
+
mock(request).get("/sessions/my_session_id") do
|
66
|
+
stub(session_response = Object.new).code {"404"}
|
67
|
+
session_response
|
67
68
|
end
|
68
|
-
lambda {Client.run}.should raise_error(Client::
|
69
|
+
lambda {Client.run}.should raise_error(Client::SessionNotFound)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
|
-
context "when the
|
73
|
+
context "when the Session run ends in with invalid status" do
|
73
74
|
it "raises an InvalidStatusResponse" do
|
74
75
|
mock_post_to_runner("*firefox")
|
75
76
|
mock_polling_returns([running_status, running_status, "status=this is an unexpected status result"])
|
@@ -78,30 +79,30 @@ module JsTestCore
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def mock_post_to_runner(selenium_browser_start_command)
|
81
|
-
mock(
|
82
|
+
mock(start_session_response = Object.new).body {"session_id=my_session_id"}
|
82
83
|
mock(request).post("/runners", "selenium_browser_start_command=#{CGI.escape(selenium_browser_start_command)}&selenium_host=localhost&selenium_port=4444") do
|
83
|
-
|
84
|
+
start_session_response
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
def mock_polling_returns(
|
88
|
-
mock(request).get("/
|
89
|
-
stub(
|
90
|
-
stub(
|
91
|
-
|
92
|
-
end.times(
|
88
|
+
def mock_polling_returns(session_statuses=[])
|
89
|
+
mock(request).get("/sessions/my_session_id") do
|
90
|
+
stub(session_response = Object.new).body {session_statuses.shift}
|
91
|
+
stub(session_response).code {"200"}
|
92
|
+
session_response
|
93
|
+
end.times(session_statuses.length)
|
93
94
|
end
|
94
95
|
|
95
96
|
def running_status
|
96
|
-
"status=#{Resources::
|
97
|
+
"status=#{Resources::Session::RUNNING}"
|
97
98
|
end
|
98
99
|
|
99
100
|
def success_status
|
100
|
-
"status=#{Resources::
|
101
|
+
"status=#{Resources::Session::SUCCESSFUL_COMPLETION}"
|
101
102
|
end
|
102
103
|
|
103
104
|
def failure_status(reason)
|
104
|
-
"status=#{Resources::
|
105
|
+
"status=#{Resources::Session::FAILURE_COMPLETION}&reason=#{reason}"
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
@@ -10,44 +10,6 @@ module JsTestCore
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "GET" do
|
13
|
-
context "when If-Modified-Since header is == the File's mtime" do
|
14
|
-
it "returns a 304 response with Content-Length: 0 and Last-Modified: File.mtime" do
|
15
|
-
path = "#{public_path}/stylesheets/example.css"
|
16
|
-
mock(connection).send_head(304, 'Content-Type' => "text/css", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path).rfc822)
|
17
|
-
connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{::File.mtime(path).rfc822}\r\n\r\n")
|
18
|
-
|
19
|
-
path_2 = "#{public_path}/javascripts/foo.js"
|
20
|
-
mock(connection).send_head(304, 'Content-Type' => "text/javascript", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path_2).rfc822)
|
21
|
-
connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{::File.mtime(path_2).rfc822}\r\n\r\n")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when If-Modified-Since header is > the File's mtime" do
|
26
|
-
it "returns a 304 response with Content-Length: 0 and Last-Modified: File.mtime" do
|
27
|
-
path = "#{public_path}/stylesheets/example.css"
|
28
|
-
mock(connection).send_head(304, 'Content-Type' => "text/css", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path).rfc822)
|
29
|
-
connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path) + 10).rfc822}\r\n\r\n")
|
30
|
-
|
31
|
-
path_2 = "#{public_path}/javascripts/foo.js"
|
32
|
-
mock(connection).send_head(304, 'Content-Type' => "text/javascript", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path_2).rfc822)
|
33
|
-
connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path_2) + 10).rfc822}\r\n\r\n")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when If-Modified-Since header is < the File's mtime" do
|
38
|
-
it "returns a 200 response with the file's contents" do
|
39
|
-
path = "#{public_path}/stylesheets/example.css"
|
40
|
-
mock(connection).send_head(200, 'Content-Type' => "text/css", 'Content-Length' => ::File.size(path), 'Last-Modified' => ::File.mtime(path).rfc822)
|
41
|
-
mock(connection).send_data(::File.read(path))
|
42
|
-
connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path) - 10).rfc822}\r\n\r\n")
|
43
|
-
|
44
|
-
path_2 = "#{public_path}/javascripts/foo.js"
|
45
|
-
mock(connection).send_head(200, 'Content-Type' => "text/javascript", 'Content-Length' => ::File.size(path_2), 'Last-Modified' => ::File.mtime(path_2).rfc822)
|
46
|
-
mock(connection).send_data(::File.read(path_2))
|
47
|
-
connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path_2) - 10).rfc822}\r\n\r\n")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
13
|
describe "GET /stylesheets/example.css" do
|
52
14
|
it "returns a page with a of files in the directory" do
|
53
15
|
path = "#{public_path}/stylesheets/example.css"
|
@@ -3,12 +3,12 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../../unit_spec_helper")
|
|
3
3
|
module JsTestCore
|
4
4
|
module Resources
|
5
5
|
describe Runner do
|
6
|
-
attr_reader :request, :driver, :
|
6
|
+
attr_reader :request, :driver, :session_id, :selenium_browser_start_command, :body
|
7
7
|
|
8
8
|
def self.before_with_selenium_browser_start_command(selenium_browser_start_command="selenium browser start command")
|
9
9
|
before do
|
10
|
-
@driver =
|
11
|
-
@
|
10
|
+
@driver = FakeSeleniumDriver.new
|
11
|
+
@session_id = FakeSeleniumDriver::SESSION_ID
|
12
12
|
@selenium_browser_start_command = selenium_browser_start_command
|
13
13
|
@body = "selenium_browser_start_command=#{selenium_browser_start_command}"
|
14
14
|
stub(Selenium::SeleniumDriver).new('localhost', 4444, selenium_browser_start_command, 'http://0.0.0.0:8080') do
|
@@ -27,13 +27,13 @@ module JsTestCore
|
|
27
27
|
before do
|
28
28
|
@runner = Runner.new(:connection => connection, :selenium_browser_start_command => selenium_browser_start_command)
|
29
29
|
stub(runner).driver {driver}
|
30
|
-
stub(driver).session_id {
|
30
|
+
stub(driver).session_id {session_id}
|
31
31
|
Runner.register(runner)
|
32
32
|
end
|
33
33
|
|
34
34
|
context "when passed an id for which there is a corresponding Runner" do
|
35
35
|
it "returns the Runner" do
|
36
|
-
Runner.find(
|
36
|
+
Runner.find(session_id).should == runner
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -48,26 +48,26 @@ module JsTestCore
|
|
48
48
|
describe ".finalize" do
|
49
49
|
attr_reader :runner
|
50
50
|
before_with_selenium_browser_start_command
|
51
|
-
describe "when there is a runner for the passed in
|
51
|
+
describe "when there is a runner for the passed in session_id" do
|
52
52
|
before do
|
53
53
|
@runner = Runner.new(:connection => connection, :selenium_browser_start_command => selenium_browser_start_command)
|
54
54
|
stub(runner).driver {driver}
|
55
55
|
stub(driver).session_id {"DEADBEEF"}
|
56
56
|
|
57
57
|
Runner.register(runner)
|
58
|
-
runner.
|
58
|
+
runner.session_id.should == session_id
|
59
59
|
end
|
60
60
|
|
61
|
-
it "finalizes the Runner that has the
|
62
|
-
mock(driver).stop
|
61
|
+
it "finalizes the Runner that has the session_id and keeps the Runner in memory" do
|
62
|
+
mock.proxy(driver).stop
|
63
63
|
mock.proxy(runner).finalize("Browser output")
|
64
|
-
Runner.find(
|
65
|
-
Runner.finalize(
|
66
|
-
Runner.find(
|
64
|
+
Runner.find(session_id).should == runner
|
65
|
+
Runner.finalize(session_id, "Browser output")
|
66
|
+
Runner.find(session_id).should == runner
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe "when there is not a runner for the passed in
|
70
|
+
describe "when there is not a runner for the passed in session_id" do
|
71
71
|
it "does nothing" do
|
72
72
|
lambda do
|
73
73
|
Runner.finalize("6666666", "nothing happens")
|
@@ -84,21 +84,27 @@ module JsTestCore
|
|
84
84
|
stub(connection).send_body
|
85
85
|
end
|
86
86
|
|
87
|
-
it "responds with a 200 and the
|
88
|
-
stub(driver).start
|
89
|
-
stub(driver).open
|
90
|
-
stub(driver).session_id {suite_id}
|
91
|
-
|
87
|
+
it "responds with a 200 and the session_id" do
|
92
88
|
mock(connection).send_head
|
93
|
-
mock(connection).send_body("
|
89
|
+
mock(connection).send_body("session_id=#{session_id}")
|
90
|
+
connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "starts the Selenium Driver, creates a SessionID cookie, and opens the spec page" do
|
94
|
+
mock(driver).start
|
95
|
+
stub(driver).session_id {session_id}
|
96
|
+
mock(driver).create_cookie("session_id=#{session_id}")
|
97
|
+
mock(driver).open("/")
|
98
|
+
mock(driver).open("/specs")
|
99
|
+
|
100
|
+
mock(Selenium::SeleniumDriver).new('localhost', 4444, selenium_browser_start_command, 'http://0.0.0.0:8080') do
|
101
|
+
driver
|
102
|
+
end
|
94
103
|
connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
95
104
|
end
|
96
105
|
|
97
106
|
describe "when a selenium_host parameter is passed into the request" do
|
98
107
|
before do
|
99
|
-
stub(driver).start
|
100
|
-
stub(driver).open
|
101
|
-
stub(driver).session_id {suite_id}
|
102
108
|
body << "&selenium_host=another-machine"
|
103
109
|
end
|
104
110
|
|
@@ -112,9 +118,6 @@ module JsTestCore
|
|
112
118
|
|
113
119
|
describe "when a selenium_host parameter is not passed into the request" do
|
114
120
|
before do
|
115
|
-
stub(driver).start
|
116
|
-
stub(driver).open
|
117
|
-
stub(driver).session_id {suite_id}
|
118
121
|
body << "&selenium_host="
|
119
122
|
end
|
120
123
|
|
@@ -128,9 +131,6 @@ module JsTestCore
|
|
128
131
|
|
129
132
|
describe "when a selenium_port parameter is passed into the request" do
|
130
133
|
before do
|
131
|
-
stub(driver).start
|
132
|
-
stub(driver).open
|
133
|
-
stub(driver).session_id {suite_id}
|
134
134
|
body << "&selenium_port=4000"
|
135
135
|
end
|
136
136
|
|
@@ -144,9 +144,6 @@ module JsTestCore
|
|
144
144
|
|
145
145
|
describe "when a selenium_port parameter is not passed into the request" do
|
146
146
|
before do
|
147
|
-
stub(driver).start
|
148
|
-
stub(driver).open
|
149
|
-
stub(driver).session_id {suite_id}
|
150
147
|
body << "&selenium_port="
|
151
148
|
end
|
152
149
|
|
@@ -159,13 +156,15 @@ module JsTestCore
|
|
159
156
|
end
|
160
157
|
|
161
158
|
describe "when a spec_url is passed into the request" do
|
162
|
-
it "runs Selenium with the passed in host and part to run the specified spec
|
159
|
+
it "runs Selenium with the passed in host and part to run the specified spec session in Firefox" do
|
163
160
|
mock(Selenium::SeleniumDriver).new('localhost', 4444, selenium_browser_start_command, 'http://another-host:8080') do
|
164
161
|
driver
|
165
162
|
end
|
166
163
|
mock(driver).start
|
167
|
-
|
168
|
-
mock(driver).
|
164
|
+
stub(driver).create_cookie
|
165
|
+
mock(driver).open("/")
|
166
|
+
mock(driver).open("/specs/subdir")
|
167
|
+
mock(driver).session_id {session_id}.at_least(1)
|
169
168
|
|
170
169
|
body << "&spec_url=http://another-host:8080/specs/subdir"
|
171
170
|
connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
@@ -179,10 +178,12 @@ module JsTestCore
|
|
179
178
|
end
|
180
179
|
end
|
181
180
|
|
182
|
-
it "uses Selenium to run the entire spec
|
181
|
+
it "uses Selenium to run the entire spec session in Firefox" do
|
183
182
|
mock(driver).start
|
184
|
-
|
185
|
-
mock(driver).
|
183
|
+
stub(driver).create_cookie
|
184
|
+
mock(driver).open("/")
|
185
|
+
mock(driver).open("/specs")
|
186
|
+
mock(driver).session_id {session_id}.at_least(1)
|
186
187
|
|
187
188
|
body << "&spec_url="
|
188
189
|
connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
@@ -198,16 +199,12 @@ module JsTestCore
|
|
198
199
|
stub(connection).send_head
|
199
200
|
stub(connection).send_body
|
200
201
|
|
201
|
-
stub(driver).start
|
202
|
-
stub(driver).open
|
203
|
-
stub(driver).session_id {suite_id}
|
204
|
-
|
205
202
|
mock(connection).send_head
|
206
|
-
mock(connection).send_body("
|
203
|
+
mock(connection).send_body("session_id=#{session_id}")
|
207
204
|
|
208
|
-
Runner.find(
|
205
|
+
Runner.find(session_id).should be_nil
|
209
206
|
connection.receive_data("POST /runners/firefox HTTP/1.1\r\nHost: _\r\n\r\n")
|
210
|
-
runner = Runner.find(
|
207
|
+
runner = Runner.find(session_id)
|
211
208
|
runner.class.should == Runner
|
212
209
|
runner.driver.should == driver
|
213
210
|
end
|
@@ -221,45 +218,68 @@ module JsTestCore
|
|
221
218
|
stub(connection).send_head
|
222
219
|
stub(connection).send_body
|
223
220
|
|
224
|
-
stub(driver).start
|
225
|
-
stub(driver).open
|
226
|
-
stub(driver).session_id {suite_id}
|
227
|
-
|
228
221
|
mock(connection).send_head
|
229
|
-
mock(connection).send_body("
|
222
|
+
mock(connection).send_body("session_id=#{session_id}")
|
230
223
|
|
231
|
-
Runner.find(
|
224
|
+
Runner.find(session_id).should be_nil
|
232
225
|
connection.receive_data("POST /runners/iexplore HTTP/1.1\r\nHost: _\r\n\r\n")
|
233
|
-
runner = Runner.find(
|
226
|
+
runner = Runner.find(session_id)
|
234
227
|
runner.class.should == Runner
|
235
228
|
runner.driver.should == driver
|
236
229
|
end
|
237
230
|
end
|
238
231
|
|
232
|
+
describe "#running?" do
|
233
|
+
before_with_selenium_browser_start_command
|
234
|
+
context "when the driver#session_started? is true" do
|
235
|
+
it "returns true" do
|
236
|
+
create_runner_connection = create_connection
|
237
|
+
stub(create_runner_connection).send_head
|
238
|
+
stub(create_runner_connection).send_body
|
239
|
+
create_runner_connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
240
|
+
|
241
|
+
runner = Resources::Runner.find(session_id)
|
242
|
+
runner.driver.session_started?.should be_true
|
243
|
+
runner.should be_running
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
context "when the driver#session_started? is false" do
|
248
|
+
it "returns false" do
|
249
|
+
create_runner_connection = create_connection
|
250
|
+
stub(create_runner_connection).send_head
|
251
|
+
stub(create_runner_connection).send_body
|
252
|
+
create_runner_connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
253
|
+
|
254
|
+
runner = Resources::Runner.find(session_id)
|
255
|
+
runner.driver.stop
|
256
|
+
runner.driver.session_started?.should be_false
|
257
|
+
runner.should_not be_running
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
239
262
|
describe "#finalize" do
|
240
263
|
attr_reader :runner
|
241
264
|
before_with_selenium_browser_start_command
|
242
265
|
before do
|
243
|
-
stub(driver).start
|
244
|
-
stub(driver).open
|
245
|
-
stub(driver).session_id {suite_id}
|
246
|
-
|
247
266
|
create_runner_connection = create_connection
|
248
267
|
stub(create_runner_connection).send_head
|
249
268
|
stub(create_runner_connection).send_body
|
250
269
|
create_runner_connection.receive_data("POST /runners HTTP/1.1\r\nHost: _\r\nContent-Length: #{body.length}\r\n\r\n#{body}")
|
251
|
-
@runner = Resources::Runner.find(
|
252
|
-
mock(driver).stop
|
270
|
+
@runner = Resources::Runner.find(session_id)
|
271
|
+
mock.proxy(driver).stop
|
253
272
|
end
|
254
273
|
|
255
|
-
it "kills the browser and stores the #
|
256
|
-
|
257
|
-
runner.finalize(
|
258
|
-
runner.
|
274
|
+
it "kills the browser and stores the #session_run_result" do
|
275
|
+
session_run_result = "The session run result"
|
276
|
+
runner.finalize(session_run_result)
|
277
|
+
runner.session_run_result.should == session_run_result
|
259
278
|
end
|
260
279
|
|
261
|
-
it "
|
262
|
-
runner.finalize("")
|
280
|
+
it "sets #session_run_result" do
|
281
|
+
runner.finalize("the result")
|
282
|
+
runner.session_run_result.should == "the result"
|
263
283
|
end
|
264
284
|
|
265
285
|
context "when passed an empty string" do
|