honkster-screw-unit-server 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +48 -0
- data/README.markdown +359 -0
- data/Rakefile +43 -0
- data/VERSION.yml +5 -0
- data/bin/screw_unit +6 -0
- data/bin/screw_unit_server +14 -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 +166 -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 +21 -0
- data/spec/functional/functional_spec.rb +25 -0
- data/spec/functional/functional_spec_helper.rb +42 -0
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/functional_suite.rb +10 -0
- data/spec/spec_suite.rb +2 -0
- data/standalone.ru +3 -0
- data/vendor/js-test-core/CHANGES +31 -0
- data/vendor/js-test-core/README +6 -0
- data/vendor/js-test-core/Rakefile +73 -0
- data/vendor/js-test-core/bin/js-test-client +0 -0
- data/vendor/js-test-core/bin/js-test-server +6 -0
- data/vendor/js-test-core/lib/js_test_core.rb +38 -0
- data/vendor/js-test-core/lib/js_test_core/app.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +139 -0
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +65 -0
- data/vendor/js-test-core/lib/js_test_core/representations.rb +13 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +25 -0
- data/vendor/js-test-core/lib/js_test_core/representations/frameworks.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +16 -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/suite.html.rb +57 -0
- data/vendor/js-test-core/lib/js_test_core/representations/suites.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/representations/suites/screw_unit.html.rb +81 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +15 -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 +28 -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/spec_file.rb +51 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +15 -0
- data/vendor/js-test-core/lib/js_test_core/server.rb +84 -0
- data/vendor/js-test-core/public/js_test_server.js +541 -0
- data/vendor/js-test-core/spec/example_framework/JsTestCore.css +0 -0
- data/vendor/js-test-core/spec/example_framework/JsTestCore.js +0 -0
- data/vendor/js-test-core/spec/example_framework/subdir/SubDirFile.js +0 -0
- data/vendor/js-test-core/spec/example_root/favicon.ico +0 -0
- data/vendor/js-test-core/spec/example_root/javascripts/foo.js +3 -0
- data/vendor/js-test-core/spec/example_root/javascripts/large_file.js +59 -0
- data/vendor/js-test-core/spec/example_root/javascripts/subdir/bar.js +1 -0
- data/vendor/js-test-core/spec/example_root/robots.txt +0 -0
- data/vendor/js-test-core/spec/example_root/stylesheets/example.css +3 -0
- data/vendor/js-test-core/spec/example_spec/custom_dir_and_suite/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/custom_suite.html +8 -0
- data/vendor/js-test-core/spec/example_spec/failing_spec.js +7 -0
- data/vendor/js-test-core/spec/example_spec/foo/failing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/foo/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/functional/functional_spec.rb +25 -0
- data/vendor/js-test-core/spec/functional/functional_spec_helper.rb +42 -0
- data/vendor/js-test-core/spec/functional/functional_spec_server_starter.rb +77 -0
- data/vendor/js-test-core/spec/functional_suite.rb +10 -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 +16 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/spec_suite.rb +3 -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 +196 -0
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +50 -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/spec_file_spec.rb +149 -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/server_spec.rb +66 -0
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +30 -0
- data/vendor/js-test-core/spec/unit_suite.rb +10 -0
- data/vendor/js-test-core/standalone.ru +1 -0
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +77 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +5 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +142 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource/path.rb +24 -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 +276 -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
- data/vendor/js-test-core/vendor/lucky-luciano/syntax_ideas.txt +34 -0
- metadata +201 -0
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
gem "thin", ">=1.2.1"
|
3
|
+
gem "erector", ">=0.6.7"
|
4
|
+
gem "selenium-client"
|
5
|
+
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
$LOAD_PATH.unshift File.expand_path("#{dir}/../vendor/lucky-luciano/lib")
|
8
|
+
require "lucky_luciano"
|
9
|
+
|
10
|
+
require "timeout"
|
11
|
+
require "selenium/client"
|
12
|
+
require "trollop"
|
13
|
+
require "json"
|
14
|
+
require "erector"
|
15
|
+
|
16
|
+
Erector::Widget.prettyprint_default = true
|
17
|
+
|
18
|
+
require "#{dir}/js_test_core/configuration"
|
19
|
+
|
20
|
+
require "#{dir}/js_test_core/resources"
|
21
|
+
require "#{dir}/js_test_core/representations"
|
22
|
+
require "#{dir}/js_test_core/server"
|
23
|
+
require "#{dir}/js_test_core/client"
|
24
|
+
require "#{dir}/js_test_core/app"
|
25
|
+
|
26
|
+
module JsTestCore
|
27
|
+
class << self
|
28
|
+
Configuration.instance = Configuration.new
|
29
|
+
|
30
|
+
def method_missing(method_name, *args, &block)
|
31
|
+
if Configuration.instance.respond_to?(method_name)
|
32
|
+
Configuration.instance.send(method_name, *args, &block)
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class App < Sinatra::Base
|
3
|
+
set :logging, true
|
4
|
+
register(JsTestCore::Resources::WebRoot.route_handler)
|
5
|
+
register(JsTestCore::Resources::CoreFile.route_handler)
|
6
|
+
register(JsTestCore::Resources::SpecFile.route_handler)
|
7
|
+
register(JsTestCore::Resources::File.route_handler)
|
8
|
+
register(JsTestCore::Resources::ImplementationsDeprecation.route_handler)
|
9
|
+
register(JsTestCore::Resources::NotFound.route_handler)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class Client
|
3
|
+
RUNNING_RUNNER_STATE = "running"
|
4
|
+
PASSED_RUNNER_STATE = "success"
|
5
|
+
FAILED_RUNNER_STATE = "failed"
|
6
|
+
FINISHED_RUNNER_STATES = [PASSED_RUNNER_STATE, FAILED_RUNNER_STATE]
|
7
|
+
|
8
|
+
DEFAULT_SELENIUM_BROWSER = "*firefox"
|
9
|
+
DEFAULT_SELENIUM_HOST = "0.0.0.0"
|
10
|
+
DEFAULT_SELENIUM_PORT = 4444
|
11
|
+
DEFAULT_SPEC_URL = "http://localhost:8080/specs"
|
12
|
+
DEFAULT_TIMEOUT = 60
|
13
|
+
|
14
|
+
class ClientException < Exception
|
15
|
+
end
|
16
|
+
|
17
|
+
class InvalidStatusResponse < ClientException
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def run(parameters={})
|
22
|
+
new(parameters).run
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_argv(argv)
|
26
|
+
opts = Trollop.options(argv) do
|
27
|
+
opt(
|
28
|
+
:selenium_browser,
|
29
|
+
"The Selenium browser (e.g. *firefox). See http://selenium-rc.openqa.org/",
|
30
|
+
:type => String,
|
31
|
+
:default => DEFAULT_SELENIUM_BROWSER
|
32
|
+
)
|
33
|
+
opt(
|
34
|
+
:selenium_host,
|
35
|
+
"The host name of the Selenium Server relative to where this file is executed",
|
36
|
+
:type => String,
|
37
|
+
:default => DEFAULT_SELENIUM_HOST
|
38
|
+
)
|
39
|
+
opt(
|
40
|
+
:selenium_port,
|
41
|
+
"The port of the Selenium Server relative to where this file is executed",
|
42
|
+
:type => Integer,
|
43
|
+
:default => DEFAULT_SELENIUM_PORT
|
44
|
+
)
|
45
|
+
opt(
|
46
|
+
:spec_url,
|
47
|
+
"The url of the js spec server, relative to the browsers running via the Selenium Server",
|
48
|
+
:type => String,
|
49
|
+
:default => DEFAULT_SPEC_URL
|
50
|
+
)
|
51
|
+
opt(
|
52
|
+
:timeout,
|
53
|
+
"The timeout limit of the test run",
|
54
|
+
:type => Integer,
|
55
|
+
:default => DEFAULT_TIMEOUT
|
56
|
+
)
|
57
|
+
end
|
58
|
+
run opts
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
attr_reader :parameters, :selenium_client, :current_status, :flushed_console
|
63
|
+
def initialize(parameters)
|
64
|
+
@parameters = parameters
|
65
|
+
@flushed_console = ""
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
if parameters[:timeout]
|
70
|
+
Timeout.timeout(parameters[:timeout]) {do_run}
|
71
|
+
else
|
72
|
+
do_run
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
def do_run
|
78
|
+
start_selenium_client
|
79
|
+
wait_for_session_to_finish
|
80
|
+
flush_console
|
81
|
+
suite_passed?
|
82
|
+
end
|
83
|
+
|
84
|
+
def start_selenium_client
|
85
|
+
uri = URI.parse(parameters[:spec_url] || DEFAULT_SPEC_URL)
|
86
|
+
@selenium_client = Selenium::Client::Driver.new(
|
87
|
+
:host => parameters[:selenium_host] || DEFAULT_SELENIUM_HOST,
|
88
|
+
:port => parameters[:selenium_port] || DEFAULT_SELENIUM_PORT,
|
89
|
+
:browser => parameters[:selenium_browser] || DEFAULT_SELENIUM_BROWSER,
|
90
|
+
:url => "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
91
|
+
)
|
92
|
+
selenium_client.start
|
93
|
+
selenium_client.open([uri.path, uri.query].compact.join("?"))
|
94
|
+
end
|
95
|
+
|
96
|
+
def wait_for_session_to_finish
|
97
|
+
while !suite_finished?
|
98
|
+
poll
|
99
|
+
flush_console
|
100
|
+
sleep 0.25
|
101
|
+
end
|
102
|
+
if suite_passed?
|
103
|
+
STDOUT.puts(PASSED_RUNNER_STATE.capitalize)
|
104
|
+
else
|
105
|
+
STDOUT.puts(FAILED_RUNNER_STATE.capitalize)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def poll
|
110
|
+
raw_status = selenium_client.get_eval("window.JsTestServer.status()")
|
111
|
+
unless raw_status.to_s == ""
|
112
|
+
@current_status = JSON.parse(raw_status)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def suite_finished?
|
117
|
+
current_status && FINISHED_RUNNER_STATES.include?(runner_state)
|
118
|
+
end
|
119
|
+
|
120
|
+
def flush_console
|
121
|
+
if current_status && console != ""
|
122
|
+
STDOUT.print(console.gsub(flushed_console, ""))
|
123
|
+
@flushed_console = console
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def suite_passed?
|
128
|
+
runner_state == PASSED_RUNNER_STATE
|
129
|
+
end
|
130
|
+
|
131
|
+
def runner_state
|
132
|
+
current_status["runner_state"]
|
133
|
+
end
|
134
|
+
|
135
|
+
def console
|
136
|
+
current_status["console"]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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_reader :host, :port, :spec_path, :root_path, :framework_path, :framework_name
|
16
|
+
attr_writer :host, :port, :framework_path, :framework_name
|
17
|
+
|
18
|
+
def initialize(params={})
|
19
|
+
params = Server::DEFAULTS.dup.merge(params)
|
20
|
+
@spec_path = ::File.expand_path(params[:spec_path])
|
21
|
+
@root_path = ::File.expand_path(params[:root_path])
|
22
|
+
@host = params[:host]
|
23
|
+
@port = params[:port]
|
24
|
+
@framework_path = params[:framework_path]
|
25
|
+
@framework_name = params[:framework_name]
|
26
|
+
end
|
27
|
+
|
28
|
+
def suite_representation_class
|
29
|
+
if framework_name
|
30
|
+
JsTestCore::Representations::Suites.const_get(framework_name.gsub("-", "_").camelcase)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def spec_path=(path)
|
35
|
+
validate_path(path)
|
36
|
+
@spec_path = path
|
37
|
+
end
|
38
|
+
|
39
|
+
def root_path=(path)
|
40
|
+
validate_path(path)
|
41
|
+
@root_path = path
|
42
|
+
end
|
43
|
+
|
44
|
+
def js_test_core_js_path
|
45
|
+
"#{library_root_dir}/public/js_test_server.js"
|
46
|
+
end
|
47
|
+
|
48
|
+
def root_url
|
49
|
+
"http://#{host}:#{port}"
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def library_root_dir
|
55
|
+
dir = File.dirname(__FILE__)
|
56
|
+
File.expand_path("#{dir}/../..")
|
57
|
+
end
|
58
|
+
|
59
|
+
def validate_path(path)
|
60
|
+
unless File.directory?(path)
|
61
|
+
raise ArgumentError, "#{path} must be a directory"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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/suite.html"
|
11
|
+
require "#{dir}/representations/dir.html"
|
12
|
+
require "#{dir}/representations/frameworks"
|
13
|
+
require "#{dir}/representations/suites"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Dir < Page
|
4
|
+
attr_reader :relative_path, :absolute_path
|
5
|
+
needs :relative_path, :absolute_path
|
6
|
+
protected
|
7
|
+
def body_content
|
8
|
+
ul do
|
9
|
+
::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
|
10
|
+
li do
|
11
|
+
a(
|
12
|
+
::File.basename(file),
|
13
|
+
:href => "#{relative_path}/#{::File.basename(file)}".gsub("//", "/")
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def title_text
|
21
|
+
"Contents of #{relative_path}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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,57 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Suite < Page
|
4
|
+
class << self
|
5
|
+
def project_js_files
|
6
|
+
@@project_js_files ||= []
|
7
|
+
end
|
8
|
+
|
9
|
+
def project_js_files=(files)
|
10
|
+
@@project_js_files = files
|
11
|
+
end
|
12
|
+
|
13
|
+
def project_css_files
|
14
|
+
@@project_css_files ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
def project_css_files=(files)
|
18
|
+
@@project_css_files = files
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :spec_files
|
23
|
+
needs :spec_files
|
24
|
+
protected
|
25
|
+
def title_text
|
26
|
+
"Js Test Core Suite"
|
27
|
+
end
|
28
|
+
|
29
|
+
def head_content
|
30
|
+
project_js_files
|
31
|
+
project_css_files
|
32
|
+
spec_script_elements
|
33
|
+
end
|
34
|
+
|
35
|
+
def spec_script_elements
|
36
|
+
spec_files.each do |file|
|
37
|
+
script :type => "text/javascript", :src => file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def project_js_files
|
42
|
+
self.class.project_js_files.each do |file|
|
43
|
+
script :src => file, :type => "text/javascript"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def project_css_files
|
48
|
+
self.class.project_css_files.each do |file|
|
49
|
+
link :href => file, :type => "text/css", :media => "screen", :rel => "stylesheet"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def body_content
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
module Suites
|
4
|
+
class ScrewUnit < JsTestCore::Representations::Suite
|
5
|
+
class << self
|
6
|
+
def jquery_js_file
|
7
|
+
@jquery_js_file ||= "/core/jquery-1.3.2.js"
|
8
|
+
end
|
9
|
+
attr_writer :jquery_js_file
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :spec_files
|
13
|
+
needs :spec_files
|
14
|
+
def title_text
|
15
|
+
"Screw Unit suite"
|
16
|
+
end
|
17
|
+
|
18
|
+
def head_content
|
19
|
+
core_js_files
|
20
|
+
script(raw(<<-JS), :type => "text/javascript")
|
21
|
+
(function($) {
|
22
|
+
var jsTestServerStatus = {"runner_state": "#{Client::RUNNING_RUNNER_STATE}", "console": ""};
|
23
|
+
|
24
|
+
JsTestServer.status = function() {
|
25
|
+
return JsTestServer.JSON.stringify(jsTestServerStatus);
|
26
|
+
};
|
27
|
+
|
28
|
+
$(Screw).bind('after', function() {
|
29
|
+
var error_text = $(".error").map(function(i, error_element) {
|
30
|
+
var element = $(error_element);
|
31
|
+
|
32
|
+
var parent_descriptions = element.parents("li.describe");
|
33
|
+
var parent_description_text = [];
|
34
|
+
|
35
|
+
for(var i=parent_descriptions.length-1; i >= 0; i--) {
|
36
|
+
parent_description_text.push($(parent_descriptions[i]).find("h1").text());
|
37
|
+
}
|
38
|
+
|
39
|
+
var it_text = element.parents("li.it").find("h2").text();
|
40
|
+
|
41
|
+
return parent_description_text.join(" ") + " " + it_text + ": " + element.text();
|
42
|
+
}).get().join("\\n");
|
43
|
+
|
44
|
+
jsTestServerStatus["console"] = error_text;
|
45
|
+
if(error_text) {
|
46
|
+
jsTestServerStatus["runner_state"] = "#{Client::FAILED_RUNNER_STATE}";
|
47
|
+
} else {
|
48
|
+
jsTestServerStatus["runner_state"] = "#{Client::PASSED_RUNNER_STATE}";
|
49
|
+
}
|
50
|
+
});
|
51
|
+
})(jQuery);
|
52
|
+
JS
|
53
|
+
project_js_files
|
54
|
+
link :rel => "stylesheet", :href => "/core/screw.css"
|
55
|
+
project_css_files
|
56
|
+
|
57
|
+
spec_script_elements
|
58
|
+
end
|
59
|
+
|
60
|
+
def core_js_files
|
61
|
+
script :src => jquery_js_file
|
62
|
+
script :src => "/js_test_server.js"
|
63
|
+
script :src => "/core/jquery.fn.js"
|
64
|
+
script :src => "/core/jquery.print.js"
|
65
|
+
script :src => "/core/screw.builder.js"
|
66
|
+
script :src => "/core/screw.matchers.js"
|
67
|
+
script :src => "/core/screw.events.js"
|
68
|
+
script :src => "/core/screw.behaviors.js"
|
69
|
+
end
|
70
|
+
|
71
|
+
def jquery_js_file
|
72
|
+
self.class.jquery_js_file
|
73
|
+
end
|
74
|
+
|
75
|
+
def body_content
|
76
|
+
div :id => "screw_unit_content"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|