screw-unit-server 0.3.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. data/CHANGES +23 -1
  2. data/README.markdown +10 -3
  3. data/Rakefile +27 -55
  4. data/VERSION.yml +4 -0
  5. data/bin/screw_unit_server +14 -4
  6. data/core/CHANGES +10 -0
  7. data/core/EXAMPLE.html +4 -4
  8. data/core/README.markdown +7 -7
  9. data/core/example/models/man.js +2 -2
  10. data/core/example/spec/suite.html +1 -1
  11. data/core/lib/jquery-1.3.2.js +4376 -0
  12. data/core/lib/jquery.fn.js +2 -1
  13. data/core/lib/jquery.print.js +13 -12
  14. data/core/lib/screw.behaviors.js +11 -9
  15. data/core/lib/screw.builder.js +26 -11
  16. data/core/lib/screw.css +2 -2
  17. data/core/lib/screw.events.js +11 -4
  18. data/core/lib/screw.matchers.js +192 -13
  19. data/core/spec/behaviors_spec.js +11 -1
  20. data/core/spec/matchers_spec.js +288 -9
  21. data/core/spec/print_spec.js +47 -8
  22. data/core/spec/suite.html +2 -1
  23. data/core/spec/with_screw_context_spec.js +9 -0
  24. data/lib/screw_unit.rb +13 -16
  25. data/lib/screw_unit/representations.rb +2 -0
  26. data/lib/screw_unit/representations/spec.html.rb +117 -0
  27. data/spec/functional/functional_spec.rb +14 -3
  28. data/spec/functional/functional_spec_helper.rb +22 -34
  29. data/spec/functional/functional_spec_server_starter.rb +68 -0
  30. data/spec/unit/js_test_core/specs/spec_file_spec.rb +45 -20
  31. data/spec/unit/unit_spec_helper.rb +24 -93
  32. data/vendor/js-test-core/CHANGES +19 -0
  33. data/vendor/js-test-core/Rakefile +2 -1
  34. data/vendor/js-test-core/lib/js_test_core.rb +26 -10
  35. data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
  36. data/vendor/js-test-core/lib/js_test_core/client.rb +97 -18
  37. data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
  38. data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
  39. data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
  40. data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
  41. data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
  42. data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
  43. data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
  44. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
  45. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
  46. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  47. data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
  48. data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -8
  49. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  50. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +44 -14
  51. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  52. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
  53. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  54. data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
  55. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
  56. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -56
  57. data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
  58. data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
  59. data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
  60. data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
  61. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
  62. data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
  63. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
  64. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
  65. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  66. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  67. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
  68. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  69. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +140 -85
  70. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
  71. data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
  72. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  73. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +61 -68
  74. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  75. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  76. data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
  77. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
  78. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +14 -89
  79. data/vendor/js-test-core/spec/unit/js_test_core/selenium_server_configuration_spec.rb +49 -0
  80. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -113
  81. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
  82. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
  83. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
  84. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  85. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  86. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
  87. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  88. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
  89. metadata +143 -129
  90. data/core/TODO +0 -2
  91. data/core/lib/jquery-1.2.3.js +0 -3408
  92. data/core/lib/screw.assets.js +0 -36
  93. data/core/lib/screw.server.js +0 -21
  94. data/lib/screw_unit/resources.rb +0 -2
  95. data/lib/screw_unit/resources/spec.rb +0 -37
  96. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -43
  97. data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
  98. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
  99. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
  100. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -52
  101. data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -15
  102. data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +0 -15
  103. data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +0 -75
  104. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
  105. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
  106. data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +0 -24
  107. data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +0 -19
  108. data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
  109. data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
  110. data/vendor/js-test-core/lib/js_test_core/server.rb +0 -111
  111. data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
  112. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
  113. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -42
  114. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
  115. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -42
  116. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -26
  117. data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +0 -24
  118. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +0 -197
  119. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -79
  120. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
  121. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +0 -94
  122. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -44
  123. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -131
  124. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -92
@@ -1,2 +0,0 @@
1
- dir = File.dirname(__FILE__)
2
- require "#{dir}/selenium/selenium_driver"
@@ -1,5 +0,0 @@
1
- module Selenium
2
- class SeleniumDriver
3
- attr_reader :session_id
4
- end
5
- end
@@ -1,111 +0,0 @@
1
- module JsTestCore
2
- class Server
3
- class << self
4
- attr_accessor :instance
5
-
6
- def run(spec_root_path, implementation_root_path, public_path, server_options = {})
7
- server_options[:Host] ||= DEFAULT_HOST
8
- server_options[:Port] ||= DEFAULT_PORT
9
- @instance = new(spec_root_path, implementation_root_path, public_path, server_options[:Host], server_options[:Port])
10
- instance.run server_options
11
- end
12
-
13
- def spec_root_path; instance.spec_root_path; end
14
- def implementation_root_path; instance.implementation_root_path; end
15
- def public_path; instance.public_path; end
16
- def core_path; instance.core_path; end
17
- def test_dir_class; instance.test_dir_class; end
18
- def test_file_class; instance.test_file_class; end
19
- def connection; instance.connection; end
20
- def request; instance.request; end
21
- def response; instance.response; end
22
- def root_url; instance.root_url; end
23
- end
24
-
25
- attr_reader :host, :port, :spec_root_path, :implementation_root_path, :public_path
26
-
27
- def initialize(spec_root_path, implementation_root_path, public_path, host=DEFAULT_HOST, port=DEFAULT_PORT)
28
- dir = ::File.dirname(__FILE__)
29
- @spec_root_path = ::File.expand_path(spec_root_path)
30
- @implementation_root_path = ::File.expand_path(implementation_root_path)
31
- @public_path = ::File.expand_path(public_path)
32
- @host = host
33
- @port = port
34
- end
35
-
36
- def run(options)
37
- server = ::Thin::Server.new(options[:Host], options[:Port], self)
38
- server.backend = ::Thin::Backends::JsTestCoreServer.new(options[:Host], options[:Port])
39
- server.backend.server = server
40
- server.start!
41
- end
42
-
43
- def call(env)
44
- self.connection = env['js_test_core.connection']
45
- self.request = Rack::Request.new(env)
46
- self.response = Rack::Response.new
47
- method = request.request_method.downcase.to_sym
48
- get_resource(request).send(method, request, response)
49
- response.finish
50
- ensure
51
- self.connection = nil
52
- self.request = nil
53
- self.response = nil
54
- end
55
-
56
- def connection
57
- Thread.current[:connection]
58
- end
59
-
60
- def request
61
- Thread.current[:request]
62
- end
63
-
64
- def response
65
- Thread.current[:response]
66
- end
67
-
68
- def root_url
69
- "http://#{host}:#{port}"
70
- end
71
-
72
- def core_path
73
- JsTestCore.core_path
74
- end
75
-
76
- def test_dir_class
77
- JsTestCore.adapter.test_dir_class
78
- end
79
-
80
- def test_file_class
81
- JsTestCore.adapter.test_file_class
82
- end
83
-
84
- protected
85
- def connection=(connection)
86
- Thread.current[:connection] = connection
87
- end
88
-
89
- def request=(request)
90
- Thread.current[:request] = request
91
- end
92
-
93
- def response=(response)
94
- Thread.current[:response] = response
95
- end
96
-
97
- def path_parts(req)
98
- request.path_info.split('/').reject { |part| part == "" }
99
- end
100
-
101
- def get_resource(request)
102
- path_parts(request).inject(Resources::WebRoot.new(public_path)) do |resource, child_resource_name|
103
- resource.locate(child_resource_name)
104
- end
105
- rescue Exception => e
106
- detailed_exception = Exception.new("Error handling path #{request.path_info}\n#{e.message}")
107
- detailed_exception.set_backtrace(e.backtrace)
108
- raise detailed_exception
109
- end
110
- end
111
- end
@@ -1,3 +0,0 @@
1
- dir = File.dirname(__FILE__)
2
- require "#{dir}/thin/js_test_core_connection"
3
- require "#{dir}/thin/backends/js_test_core_server"
@@ -1,9 +0,0 @@
1
- module Thin
2
- module Backends
3
- class JsTestCoreServer < TcpServer
4
- def connect
5
- @signature = EventMachine.start_server(@host, @port, JsTestCoreConnection, &method(:initialize_connection))
6
- end
7
- end
8
- end
9
- end
@@ -1,42 +0,0 @@
1
- module Thin
2
- class JsTestCoreConnection < Connection
3
- def process
4
- # Add client info to the request env
5
- @request.remote_address = remote_address
6
-
7
- env = @request.env
8
- env['js_test_core.connection'] = self
9
- @response.status, @response.headers, @response.body = @app.call(env)
10
- send_data @response.head
11
- if !@response.body.empty? || @response.headers.to_s.include?("Content-Length: 0")
12
- send_body @response.body
13
- end
14
- rescue Exception => e
15
- handle_error e
16
- end
17
-
18
- def send_body(rack_response)
19
- rack_response.each do |chunk|
20
- send_data chunk
21
- end
22
- # If no more request on that same connection, we close it.
23
- close_connection_after_writing unless persistent?
24
- rescue Exception => e
25
- handle_error e
26
- ensure
27
- @request.close rescue nil
28
- @response.close rescue nil
29
-
30
- # Prepare the connection for another request if the client
31
- # supports HTTP pipelining (persistent connection).
32
- post_init if persistent?
33
- end
34
-
35
- def handle_error(error)
36
- log "!! Unexpected error while processing request: #{error.message}"
37
- log error.backtrace
38
- log_error
39
- close_connection rescue nil
40
- end
41
- end
42
- end
@@ -1,45 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
2
-
3
- module JsTestCore
4
- describe RailsServer do
5
- it "subclasses Server" do
6
- RailsServer.superclass.should == Server
7
- end
8
-
9
- describe ".run" do
10
- attr_reader :rails_root
11
- before do
12
- @rails_root = "/rails/root"
13
- Server.instance = nil
14
- end
15
-
16
- it "initializes the RailsServer and runs the Thin Handler and sets Server.instance to the RailsServer instance" do
17
- host = DEFAULT_HOST
18
- port = DEFAULT_PORT
19
- server_instance = nil
20
- mock.proxy(RailsServer).new(
21
- rails_root,
22
- host,
23
- port
24
- ) do |new_instance|
25
- server_instance = new_instance
26
- end
27
-
28
- mock(EventMachine).run.yields
29
- mock(EventMachine).start_server(host, port, ::Thin::JsTestCoreConnection)
30
- RailsServer.run(rails_root)
31
- Server.instance.should == server_instance
32
- end
33
- end
34
-
35
- describe "#initialize" do
36
- it "sets the server paths based on the passed in rails root" do
37
- rails_root = "/rails/root"
38
- server = RailsServer.new(rails_root)
39
- server.spec_root_path.should == "#{rails_root}/spec/javascripts"
40
- server.implementation_root_path.should == "#{rails_root}/public/javascripts"
41
- server.public_path.should == "#{rails_root}/public"
42
- end
43
- end
44
- end
45
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
-
3
- module JsTestCore
4
- module Resources
5
- describe Dir do
6
- attr_reader :dir, :absolute_path, :relative_path
7
-
8
- describe "#locate" do
9
- before do
10
- @absolute_path = core_path
11
- @relative_path = "/core"
12
- @dir = Resources::Dir.new(absolute_path, relative_path)
13
- end
14
-
15
- describe "when passed a name of a real file" do
16
- it "returns a Resources::File representing it" do
17
- file = dir.locate("JsTestCore.css")
18
- file.relative_path.should == "/core/JsTestCore.css"
19
- file.absolute_path.should == "#{core_path}/JsTestCore.css"
20
- end
21
- end
22
- end
23
-
24
- describe "#glob" do
25
- before do
26
- @absolute_path = spec_root_path
27
- @relative_path = "/specs"
28
- @dir = Resources::Dir.new(absolute_path, relative_path)
29
- end
30
-
31
- it "returns an array of matching Files under this directory with the correct relative paths" do
32
- globbed_files = dir.glob("/**/*_spec.js")
33
-
34
- globbed_files.size.should == 3
35
- globbed_files.should contain_spec_file_with_correct_paths("/failing_spec.js")
36
- globbed_files.should contain_spec_file_with_correct_paths("/foo/failing_spec.js")
37
- globbed_files.should contain_spec_file_with_correct_paths("/foo/passing_spec.js")
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
-
3
- module JsTestCore
4
- module Resources
5
- describe FileNotFound do
6
- attr_reader :request, :response, :file_not_found
7
-
8
- before do
9
- WebRoot.dispatch_specs
10
- stub(EventMachine).send_data
11
- stub(EventMachine).close_connection
12
- @request = create_request('get', '/invalid')
13
- @response = Rack::Response.new
14
- @file_not_found = FileNotFound.new('invalid')
15
- end
16
-
17
- describe "#get" do
18
- it "returns a 404 response code with an error message" do
19
- file_not_found.get(request, response)
20
- response.status.should == 404
21
- response.body.should include("Path invalid not found. You may want to try the /specs directory.")
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,24 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
-
3
- module JsTestCore
4
- module Resources
5
- describe Runners do
6
- attr_reader :runner
7
- before do
8
- @runner = Runners.new
9
- end
10
-
11
- describe "#locate" do
12
- it "when passed 'firefox', returns a Firefox1Runner" do
13
- runner.locate('firefox').is_a?(Runners::FirefoxRunner).should be_true
14
- end
15
-
16
- it "when not passed 'firefox', raises an error" do
17
- lambda do
18
- runner.locate('invalid')
19
- end.should raise_error
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,197 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../unit_spec_helper")
2
-
3
- module JsTestCore
4
- module Resources
5
- describe Runners::FirefoxRunner do
6
- attr_reader :runner, :request, :response, :driver, :suite_id
7
-
8
- before do
9
- Thread.current[:connection] = connection
10
- @driver = "Selenium Driver"
11
- @suite_id = 12345
12
- stub(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
13
- driver
14
- end
15
- end
16
-
17
- describe ".resume" do
18
- describe "when there is a runner for the passed in suite_id" do
19
- before do
20
- @request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
21
- @response = Rack::Response.new
22
- @runner = Runners::FirefoxRunner.new
23
- stub(Thread).start.yields
24
-
25
- stub(driver).start
26
- stub(driver).open
27
- stub(driver).session_id {suite_id}
28
- stub(driver).stop
29
- stub(EventMachine).send_data
30
- stub(EventMachine).close_connection
31
-
32
- runner.post(request, response)
33
- runner.suite_id.should == suite_id
34
- end
35
-
36
- it "removes and finalizes the instance that has the suite_id" do
37
- mock.proxy(runner).finalize("Browser output")
38
- Runners::FirefoxRunner.send(:instances)[suite_id].should == runner
39
- Runners::FirefoxRunner.resume(suite_id, "Browser output")
40
- Runners::FirefoxRunner.send(:instances)[suite_id].should be_nil
41
- end
42
- end
43
-
44
- describe "when there is not a runner for the passed in suite_id" do
45
- it "does nothing" do
46
- lambda do
47
- Runners::FirefoxRunner.resume("invalid", "nothing happens")
48
- end.should_not raise_error
49
- end
50
- end
51
- end
52
-
53
- describe "#post" do
54
- attr_reader :firefox_profile_path
55
- before do
56
- @request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
57
- @response = Rack::Response.new
58
- @runner = Runners::FirefoxRunner.new
59
- stub(Thread).start.yields
60
- end
61
-
62
- it "keeps the connection open" do
63
- stub(driver).start
64
- stub(driver).open
65
- stub(driver).session_id {suite_id}
66
- dont_allow(EventMachine).send_data
67
- dont_allow(EventMachine).close_connection
68
- runner.post(request, response)
69
-
70
- response.body.should be_empty
71
- end
72
-
73
- describe "when a selenium_host parameter is passed into the request" do
74
- before do
75
- request['selenium_host'] = "another-machine"
76
- stub(driver).start
77
- stub(driver).open
78
- stub(driver).session_id {suite_id}
79
- end
80
-
81
- it "starts the Selenium Driver with the passed in selenium_host" do
82
- mock(Selenium::SeleniumDriver).new('another-machine', 4444, '*firefox', 'http://0.0.0.0:8080') do
83
- driver
84
- end
85
- runner.post(request, response)
86
- end
87
- end
88
-
89
- describe "when a selenium_host parameter is not passed into the request" do
90
- before do
91
- request['selenium_host'].should be_nil
92
- stub(driver).start
93
- stub(driver).open
94
- stub(driver).session_id {suite_id}
95
- end
96
-
97
- it "starts the Selenium Driver from localhost" do
98
- mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
99
- driver
100
- end
101
- runner.post(request, response)
102
- end
103
- end
104
-
105
- describe "when a selenium_port parameter is passed into the request" do
106
- before do
107
- request['selenium_port'] = "4000"
108
- stub(driver).start
109
- stub(driver).open
110
- stub(driver).session_id {suite_id}
111
- end
112
-
113
- it "starts the Selenium Driver with the passed in selenium_port" do
114
- mock(Selenium::SeleniumDriver).new('localhost', 4000, '*firefox', 'http://0.0.0.0:8080') do
115
- driver
116
- end
117
- runner.post(request, response)
118
- end
119
- end
120
-
121
- describe "when a selenium_port parameter is not passed into the request" do
122
- before do
123
- request['selenium_port'].should be_nil
124
- stub(driver).start
125
- stub(driver).open
126
- stub(driver).session_id {suite_id}
127
- end
128
-
129
- it "starts the Selenium Driver from localhost" do
130
- mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
131
- driver
132
- end
133
- runner.post(request, response)
134
- end
135
- end
136
-
137
- describe "when a spec_url is passed into the request" do
138
- before do
139
- request['spec_url'] = "http://another-host:8080/specs/subdir"
140
- end
141
-
142
- it "runs Selenium with the passed in host and part to run the specified spec suite in Firefox" do
143
- mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://another-host:8080') do
144
- driver
145
- end
146
- mock(driver).start
147
- mock(driver).open("http://another-host:8080/specs/subdir")
148
- mock(driver).session_id {suite_id}
149
-
150
- runner.post(request, response)
151
- end
152
- end
153
-
154
- describe "when a spec_url is not passed into the request" do
155
- before do
156
- request['spec_url'].should be_nil
157
- mock(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
158
- driver
159
- end
160
- end
161
-
162
- it "uses Selenium to run the entire spec suite in Firefox" do
163
- mock(driver).start
164
- mock(driver).open("http://0.0.0.0:8080/specs")
165
- mock(driver).session_id {suite_id}
166
-
167
- runner.post(request, response)
168
- end
169
- end
170
- end
171
-
172
- describe "#finalize" do
173
- before do
174
- @request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
175
- @response = Rack::Response.new
176
- @runner = Runners::FirefoxRunner.new
177
- stub(driver).start
178
- stub(driver).open
179
- stub(driver).session_id {suite_id}
180
- runner.post(request, response)
181
- end
182
-
183
- it "kills the browser, sends the response body, and close the connection" do
184
- mock(driver).stop
185
- data = ""
186
- stub(EventMachine).send_data do |signature, data, data_length|
187
- data << data
188
- end
189
- mock(connection).close_connection_after_writing
190
-
191
- runner.finalize("The text")
192
- data.should include("The text")
193
- end
194
- end
195
- end
196
- end
197
- end