pivotal-screw-unit-server 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +27 -0
- data/README.markdown +354 -0
- data/Rakefile +42 -0
- data/VERSION.yml +4 -0
- data/bin/screw_unit +6 -0
- data/bin/screw_unit_server +20 -0
- data/core/CHANGES +10 -0
- data/core/EXAMPLE.html +68 -0
- data/core/LICENSE +22 -0
- data/core/README.markdown +307 -0
- data/core/example/models/cat.js +5 -0
- data/core/example/models/man.js +17 -0
- data/core/example/spec/matchers/have.js +8 -0
- data/core/example/spec/models/cat_spec.js +31 -0
- data/core/example/spec/models/man_spec.js +34 -0
- data/core/example/spec/spec_helper.js +5 -0
- data/core/example/spec/suite.html +25 -0
- data/core/lib/jquery-1.3.2.js +4376 -0
- data/core/lib/jquery.fn.js +30 -0
- data/core/lib/jquery.print.js +109 -0
- data/core/lib/screw.behaviors.js +93 -0
- data/core/lib/screw.builder.js +95 -0
- data/core/lib/screw.css +90 -0
- data/core/lib/screw.events.js +45 -0
- data/core/lib/screw.matchers.js +244 -0
- data/core/spec/behaviors_spec.js +188 -0
- data/core/spec/matchers_spec.js +372 -0
- data/core/spec/print_spec.js +158 -0
- data/core/spec/spec_helper.js +0 -0
- data/core/spec/suite.html +19 -0
- data/core/spec/with_screw_context_spec.js +9 -0
- data/init.rb +0 -0
- data/lib/screw_unit.rb +23 -0
- data/lib/screw_unit/representations.rb +2 -0
- data/lib/screw_unit/representations/spec.html.rb +117 -0
- data/spec/functional/functional_spec.rb +25 -0
- data/spec/functional/functional_spec_helper.rb +43 -0
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/functional_suite.rb +10 -0
- data/spec/spec_suite.rb +3 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +68 -0
- data/spec/unit/unit_spec_helper.rb +51 -0
- data/spec/unit_suite.rb +10 -0
- data/vendor/js-test-core/CHANGES +28 -0
- data/vendor/js-test-core/README +12 -0
- data/vendor/js-test-core/Rakefile +73 -0
- data/vendor/js-test-core/lib/js_test_core.rb +46 -0
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +129 -0
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
- data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
- data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
- data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
- data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
- data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +62 -0
- data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
- data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
- data/vendor/js-test-core/spec/example_core/JsTestCore.css +0 -0
- data/vendor/js-test-core/spec/example_core/JsTestCore.js +0 -0
- data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
- data/vendor/js-test-core/spec/example_public/favicon.ico +0 -0
- data/vendor/js-test-core/spec/example_public/javascripts/foo.js +3 -0
- data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
- data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
- data/vendor/js-test-core/spec/example_public/robots.txt +0 -0
- data/vendor/js-test-core/spec/example_public/stylesheets/example.css +3 -0
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
- data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
- data/vendor/js-test-core/spec/example_specs/failing_spec.js +5 -0
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +6 -0
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +6 -0
- data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
- data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
- data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/spec_suite.rb +2 -0
- data/vendor/js-test-core/spec/specs/failing_spec.js +0 -0
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +192 -0
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
- data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +81 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +28 -0
- data/vendor/js-test-core/spec/unit/js_test_core/selenium_server_configuration_spec.rb +49 -0
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +28 -0
- data/vendor/js-test-core/spec/unit_suite.rb +10 -0
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
- metadata +198 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class Configuration
|
3
|
+
class << self
|
4
|
+
attr_accessor :instance
|
5
|
+
|
6
|
+
def method_missing(method_name, *args, &block)
|
7
|
+
if Configuration.instance.respond_to?(method_name)
|
8
|
+
Configuration.instance.send(method_name, *args, &block)
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :host, :port, :spec_root_path, :public_path, :core_path
|
16
|
+
|
17
|
+
def initialize(params={})
|
18
|
+
params = {
|
19
|
+
:spec_root_path => File.expand_path("./specs/javascripts"),
|
20
|
+
:public_path => File.expand_path("./public"),
|
21
|
+
:host => DEFAULT_HOST,
|
22
|
+
:port => DEFAULT_PORT,
|
23
|
+
}.merge(params)
|
24
|
+
@spec_root_path = ::File.expand_path(params[:spec_root_path])
|
25
|
+
@public_path = ::File.expand_path(params[:public_path])
|
26
|
+
@host = params[:host]
|
27
|
+
@port = params[:port]
|
28
|
+
@core_path = params[:core_path]
|
29
|
+
end
|
30
|
+
|
31
|
+
def root_url
|
32
|
+
"http://#{host}:#{port}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Models
|
3
|
+
class SeleniumSession
|
4
|
+
class << self
|
5
|
+
def find(id)
|
6
|
+
instances[id.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
def register(selenium_session)
|
10
|
+
instances[selenium_session.session_id] = selenium_session
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def instances
|
15
|
+
@instances ||= {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :spec_url, :selenium_browser_start_command, :selenium_host, :selenium_port, :http_address, :driver, :run_result
|
20
|
+
|
21
|
+
def initialize(params={})
|
22
|
+
@spec_url = params[:spec_url]
|
23
|
+
@selenium_browser_start_command = params[:selenium_browser_start_command]
|
24
|
+
@selenium_host = params[:selenium_host]
|
25
|
+
@selenium_port = params[:selenium_port]
|
26
|
+
|
27
|
+
memoized_parsed_spec_url = parsed_spec_url
|
28
|
+
@http_address = "#{memoized_parsed_spec_url.scheme}://#{memoized_parsed_spec_url.host}:#{memoized_parsed_spec_url.port}"
|
29
|
+
|
30
|
+
@driver = Selenium::Client::Driver.new(
|
31
|
+
selenium_host,
|
32
|
+
selenium_port,
|
33
|
+
selenium_browser_start_command,
|
34
|
+
http_address
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def start
|
39
|
+
begin
|
40
|
+
driver.start
|
41
|
+
rescue Errno::ECONNREFUSED => e
|
42
|
+
raise Errno::ECONNREFUSED, "Cannot connect to Selenium Server at #{http_address}. To start the selenium server, run `selenium`."
|
43
|
+
end
|
44
|
+
self.class.register(self)
|
45
|
+
Thread.start do
|
46
|
+
driver.open("/")
|
47
|
+
driver.create_cookie("session_id=#{session_id}")
|
48
|
+
driver.open(parsed_spec_url.path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def session_id
|
53
|
+
driver.session_id
|
54
|
+
end
|
55
|
+
|
56
|
+
def finish(run_result)
|
57
|
+
driver.stop
|
58
|
+
@run_result = run_result.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def running?
|
62
|
+
driver.session_started?
|
63
|
+
end
|
64
|
+
|
65
|
+
def successful?
|
66
|
+
!running? && run_result.empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
def failed?
|
70
|
+
!running? && !successful?
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
def parsed_spec_url
|
76
|
+
URI.parse(spec_url)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
module JsTestCore
|
4
|
+
module Representations
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "#{dir}/representations/page.html"
|
9
|
+
require "#{dir}/representations/not_found.html"
|
10
|
+
require "#{dir}/representations/spec.html"
|
11
|
+
require "#{dir}/representations/dir.html"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Dir < Page
|
4
|
+
needs :relative_path, :absolute_path
|
5
|
+
protected
|
6
|
+
def body_content
|
7
|
+
ul do
|
8
|
+
::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
|
9
|
+
li do
|
10
|
+
a(
|
11
|
+
::File.basename(file),
|
12
|
+
:href => "#{relative_path}/#{::File.basename(file)}".gsub("//", "/")
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def title_text
|
20
|
+
"Contents of #{relative_path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Page < Erector::Widget
|
4
|
+
def content(&block)
|
5
|
+
rawtext %Q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">}
|
6
|
+
html :xmlns => "http://www.w3.org/1999/xhtml", :"xml:lang" => "en" do
|
7
|
+
head do
|
8
|
+
meta :"http-equiv" => "Content-Type", :content => "text/html;charset=UTF-8"
|
9
|
+
title title_text
|
10
|
+
head_content
|
11
|
+
end
|
12
|
+
body do
|
13
|
+
body_content(&block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
def head_content
|
20
|
+
end
|
21
|
+
|
22
|
+
def title_text
|
23
|
+
"Thin Rest"
|
24
|
+
end
|
25
|
+
|
26
|
+
def body_content(&block)
|
27
|
+
yield(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def path
|
31
|
+
helpers.rack_request.path_info
|
32
|
+
end
|
33
|
+
|
34
|
+
def script_elements
|
35
|
+
end
|
36
|
+
|
37
|
+
def link_elements
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Spec < Page
|
4
|
+
needs :spec_files
|
5
|
+
protected
|
6
|
+
def title_text
|
7
|
+
"Js Test Core Suite"
|
8
|
+
end
|
9
|
+
|
10
|
+
def head_content
|
11
|
+
spec_script_elements
|
12
|
+
end
|
13
|
+
|
14
|
+
def spec_script_elements
|
15
|
+
spec_files.each do |file|
|
16
|
+
script :type => "text/javascript", :src => file
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def body_content
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
module JsTestCore
|
4
|
+
module Resources
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "#{dir}/resources/resource"
|
9
|
+
require "#{dir}/resources/selenium_session"
|
10
|
+
require "#{dir}/resources/file"
|
11
|
+
require "#{dir}/resources/spec_file"
|
12
|
+
require "#{dir}/resources/core_file"
|
13
|
+
require "#{dir}/resources/web_root"
|
14
|
+
require "#{dir}/resources/not_found"
|
15
|
+
|
16
|
+
require "#{dir}/resources/implementations_deprecation"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class CoreFile < File
|
4
|
+
map "/core"
|
5
|
+
|
6
|
+
get "/?" do
|
7
|
+
do_get
|
8
|
+
end
|
9
|
+
|
10
|
+
get "*" do
|
11
|
+
do_get
|
12
|
+
end
|
13
|
+
|
14
|
+
def absolute_path
|
15
|
+
@absolute_path ||= ::File.expand_path("#{core_path}#{relative_path.gsub(%r{^/core}, "")}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class File < Resource
|
4
|
+
map "*"
|
5
|
+
|
6
|
+
MIME_TYPES = {
|
7
|
+
'.html' => 'text/html',
|
8
|
+
'.htm' => 'text/html',
|
9
|
+
'.js' => 'text/javascript',
|
10
|
+
'.css' => 'text/css',
|
11
|
+
'.png' => 'image/png',
|
12
|
+
'.jpg' => 'image/jpeg',
|
13
|
+
'.jpeg' => 'image/jpeg',
|
14
|
+
'.gif' => 'image/gif',
|
15
|
+
}
|
16
|
+
|
17
|
+
get "*" do
|
18
|
+
do_get
|
19
|
+
end
|
20
|
+
|
21
|
+
def relative_path
|
22
|
+
@relative_path ||= request.path_info
|
23
|
+
end
|
24
|
+
|
25
|
+
def absolute_path
|
26
|
+
@absolute_path ||= ::File.expand_path("#{public_path}#{relative_path}")
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def do_get
|
32
|
+
if ::File.exists?(absolute_path)
|
33
|
+
if ::File.directory?(absolute_path)
|
34
|
+
render_dir
|
35
|
+
else
|
36
|
+
render_file
|
37
|
+
end
|
38
|
+
else
|
39
|
+
pass
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_dir
|
44
|
+
Representations::Dir.new(:relative_path => relative_path, :absolute_path => absolute_path).to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_file
|
48
|
+
extension = ::File.extname(absolute_path)
|
49
|
+
content_type = MIME_TYPES[extension] || 'text/html'
|
50
|
+
[
|
51
|
+
200,
|
52
|
+
{
|
53
|
+
'Content-Type' => content_type,
|
54
|
+
'Last-Modified' => ::File.mtime(absolute_path).rfc822,
|
55
|
+
'Content-Length' => ::File.size(absolute_path)
|
56
|
+
},
|
57
|
+
::File.read(absolute_path)
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class ImplementationsDeprecation < Resource
|
4
|
+
map "/implementations"
|
5
|
+
|
6
|
+
get "*" do
|
7
|
+
new_path = File.path("javascripts", *params["splat"])
|
8
|
+
[301, {'Location' => new_path}, "This page has been moved to #{new_path}"]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class NotFound < Resource
|
4
|
+
map "*"
|
5
|
+
|
6
|
+
get "/" do
|
7
|
+
call
|
8
|
+
end
|
9
|
+
|
10
|
+
put "/" do
|
11
|
+
call
|
12
|
+
end
|
13
|
+
|
14
|
+
post "/" do
|
15
|
+
call
|
16
|
+
end
|
17
|
+
|
18
|
+
delete "/" do
|
19
|
+
call
|
20
|
+
end
|
21
|
+
|
22
|
+
def call
|
23
|
+
body = Representations::NotFound.new(:message => "File #{request.path_info} not found").to_s
|
24
|
+
[
|
25
|
+
404,
|
26
|
+
{
|
27
|
+
"Content-Type" => "text/html",
|
28
|
+
"Content-Length" => body.size.to_s
|
29
|
+
},
|
30
|
+
body
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class Resource < LuckyLuciano::Resource
|
4
|
+
protected
|
5
|
+
|
6
|
+
def spec_root_path; server.spec_root_path; end
|
7
|
+
def public_path; server.public_path; end
|
8
|
+
def core_path; server.core_path; end
|
9
|
+
def root_url; server.root_url; end
|
10
|
+
|
11
|
+
def server
|
12
|
+
JsTestCore::Configuration
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|