screw-unit-server 0.3.0
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.
- data/CHANGES +5 -0
- data/README.markdown +347 -0
- data/Rakefile +70 -0
- data/bin/screw_unit +6 -0
- data/bin/screw_unit_server +10 -0
- data/core/EXAMPLE.html +68 -0
- data/core/LICENSE +22 -0
- data/core/README.markdown +307 -0
- data/core/TODO +2 -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.2.3.js +3408 -0
- data/core/lib/jquery.fn.js +29 -0
- data/core/lib/jquery.print.js +108 -0
- data/core/lib/screw.assets.js +36 -0
- data/core/lib/screw.behaviors.js +91 -0
- data/core/lib/screw.builder.js +80 -0
- data/core/lib/screw.css +90 -0
- data/core/lib/screw.events.js +38 -0
- data/core/lib/screw.matchers.js +65 -0
- data/core/lib/screw.server.js +21 -0
- data/core/spec/behaviors_spec.js +178 -0
- data/core/spec/matchers_spec.js +93 -0
- data/core/spec/print_spec.js +119 -0
- data/core/spec/spec_helper.js +0 -0
- data/core/spec/suite.html +18 -0
- data/init.rb +0 -0
- data/lib/screw_unit.rb +26 -0
- data/lib/screw_unit/resources.rb +2 -0
- data/lib/screw_unit/resources/spec.rb +37 -0
- data/spec/functional/functional_spec.rb +14 -0
- data/spec/functional/functional_spec_helper.rb +55 -0
- data/spec/functional_suite.rb +10 -0
- data/spec/spec_suite.rb +3 -0
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +43 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +43 -0
- data/spec/unit/unit_spec_helper.rb +120 -0
- data/spec/unit_suite.rb +10 -0
- data/vendor/js-test-core/CHANGES +9 -0
- data/vendor/js-test-core/README +12 -0
- data/vendor/js-test-core/Rakefile +72 -0
- data/vendor/js-test-core/lib/js_test_core.rb +30 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +50 -0
- data/vendor/js-test-core/lib/js_test_core/rack.rb +2 -0
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +5 -0
- data/vendor/js-test-core/lib/js_test_core/rails_server.rb +22 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +52 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +32 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +15 -0
- data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +15 -0
- data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +75 -0
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +50 -0
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +17 -0
- data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +19 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +62 -0
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +2 -0
- data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +5 -0
- data/vendor/js-test-core/lib/js_test_core/server.rb +111 -0
- data/vendor/js-test-core/lib/js_test_core/thin.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +9 -0
- data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +42 -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_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/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/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_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 +137 -0
- data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +45 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +42 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +26 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +88 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +24 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +197 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +79 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +42 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +94 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +44 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +103 -0
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +131 -0
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +92 -0
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +125 -0
- data/vendor/js-test-core/spec/unit_suite.rb +10 -0
- metadata +186 -0
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<script src="../lib/jquery-1.2.3.js"></script>
|
|
4
|
+
<script src="../lib/jquery.fn.js"></script>
|
|
5
|
+
<script src="../lib/jquery.print.js"></script>
|
|
6
|
+
<script src="../lib/screw.builder.js"></script>
|
|
7
|
+
<script src="../lib/screw.matchers.js"></script>
|
|
8
|
+
<script src="../lib/screw.events.js"></script>
|
|
9
|
+
<script src="../lib/screw.behaviors.js"></script>
|
|
10
|
+
<script src="spec_helper.js"></script>
|
|
11
|
+
<script src="behaviors_spec.js"></script>
|
|
12
|
+
<script src="matchers_spec.js"></script>
|
|
13
|
+
<script src="print_spec.js"></script>
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../lib/screw.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body></body>
|
|
18
|
+
</html>
|
data/init.rb
ADDED
|
File without changes
|
data/lib/screw_unit.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
|
|
3
|
+
dir = File.dirname(__FILE__)
|
|
4
|
+
$:.unshift(File.expand_path("#{dir}/../vendor/js-test-core/lib"))
|
|
5
|
+
require "js_test_core"
|
|
6
|
+
JsTestCore::Resources::WebRoot.dispatch_specs
|
|
7
|
+
|
|
8
|
+
require "#{dir}/screw_unit/resources"
|
|
9
|
+
|
|
10
|
+
module ScrewUnit
|
|
11
|
+
DEFAULT_HOST = JsTestCore::DEFAULT_HOST
|
|
12
|
+
DEFAULT_PORT = JsTestCore::DEFAULT_PORT
|
|
13
|
+
|
|
14
|
+
Server = JsTestCore::Server
|
|
15
|
+
RailsServer = JsTestCore::RailsServer
|
|
16
|
+
Client = JsTestCore::Client
|
|
17
|
+
end
|
|
18
|
+
JsTestCore.core_path = File.expand_path("#{dir}/../core/lib")
|
|
19
|
+
|
|
20
|
+
class JsTestCore::Resources::Specs::SpecFile
|
|
21
|
+
include ScrewUnit::Resources::Spec
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class JsTestCore::Resources::Specs::SpecDir
|
|
25
|
+
include ScrewUnit::Resources::Spec
|
|
26
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module ScrewUnit
|
|
2
|
+
module Resources
|
|
3
|
+
module Spec
|
|
4
|
+
def get(request, response)
|
|
5
|
+
html = <<-HTML
|
|
6
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
7
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
|
8
|
+
<head>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
|
10
|
+
<title>ScrewUnit results</title>
|
|
11
|
+
<script src="/core/jquery-1.2.3.js"></script>
|
|
12
|
+
<script src="/core/jquery.fn.js"></script>
|
|
13
|
+
<script src="/core/jquery.print.js"></script>
|
|
14
|
+
<script src="/core/screw.builder.js"></script>
|
|
15
|
+
<script src="/core/screw.matchers.js"></script>
|
|
16
|
+
<script src="/core/screw.events.js"></script>
|
|
17
|
+
<script src="/core/screw.behaviors.js"></script>
|
|
18
|
+
<script src="/core/screw.assets.js"></script>
|
|
19
|
+
<script src="/core/screw.server.js"></script>
|
|
20
|
+
<link rel="stylesheet" href="/core/screw.css">
|
|
21
|
+
HTML
|
|
22
|
+
spec_files.each do |file|
|
|
23
|
+
html << %{<script type="text/javascript" src="#{file.relative_path}"></script>\n}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
html << <<-HTML
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<div id="screw_unit_content"></div>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
32
|
+
HTML
|
|
33
|
+
response.body = html.gsub(/^ /, "")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/functional_spec_helper")
|
|
2
|
+
|
|
3
|
+
describe "ScrewUnit" do
|
|
4
|
+
it "runs a full passing Suite" do
|
|
5
|
+
mock(ScrewUnit::Client).puts("SUCCESS")
|
|
6
|
+
ScrewUnit::Client.run(:spec_url => "#{root_url}/specs/foo/passing_spec")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "runs a full failing Suite" do
|
|
10
|
+
mock(ScrewUnit::Client).puts("FAILURE")
|
|
11
|
+
mock(ScrewUnit::Client).puts('expected true to equal false')
|
|
12
|
+
ScrewUnit::Client.run(:spec_url => "#{root_url}/specs/foo/failing_spec")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "spec"
|
|
3
|
+
|
|
4
|
+
dir = File.dirname(__FILE__)
|
|
5
|
+
$LOAD_PATH.unshift "#{dir}/../../lib"
|
|
6
|
+
require "screw_unit"
|
|
7
|
+
require "hpricot"
|
|
8
|
+
require "lsof"
|
|
9
|
+
|
|
10
|
+
Spec::Runner.configure do |config|
|
|
11
|
+
config.mock_with :rr
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Thin::Logging.silent = false
|
|
15
|
+
Thin::Logging.debug = true
|
|
16
|
+
|
|
17
|
+
module WaitFor
|
|
18
|
+
extend self
|
|
19
|
+
def wait_for(time=5)
|
|
20
|
+
Timeout.timeout(time) do
|
|
21
|
+
loop do
|
|
22
|
+
value = yield
|
|
23
|
+
return value if value
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module Spec::Example::ExampleMethods
|
|
30
|
+
include WaitFor
|
|
31
|
+
attr_reader :spec_root_path, :implementation_root_path, :public_path
|
|
32
|
+
before(:all) do
|
|
33
|
+
Lsof.kill(8080)
|
|
34
|
+
wait_for do
|
|
35
|
+
!Lsof.running?(8080)
|
|
36
|
+
end
|
|
37
|
+
dir = File.dirname(__FILE__)
|
|
38
|
+
@spec_root_path = "#{dir}/../example_specs"
|
|
39
|
+
@public_path = "#{dir}/../example_public"
|
|
40
|
+
@implementation_root_path = "#{public_path}/javascripts"
|
|
41
|
+
unless $screw_unit_server_started
|
|
42
|
+
Thread.start do
|
|
43
|
+
ScrewUnit::Server.run(spec_root_path, implementation_root_path, public_path)
|
|
44
|
+
end
|
|
45
|
+
$screw_unit_server_started = true
|
|
46
|
+
end
|
|
47
|
+
wait_for do
|
|
48
|
+
Lsof.running?(8080)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def root_url
|
|
53
|
+
"http://#{ScrewUnit::DEFAULT_HOST}:#{ScrewUnit::DEFAULT_PORT}"
|
|
54
|
+
end
|
|
55
|
+
end
|
data/spec/spec_suite.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
|
2
|
+
|
|
3
|
+
module JsTestCore
|
|
4
|
+
module Resources
|
|
5
|
+
module Specs
|
|
6
|
+
describe SpecDir do
|
|
7
|
+
attr_reader :dir
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
stub(EventMachine).send_data
|
|
11
|
+
stub(EventMachine).close_connection
|
|
12
|
+
@dir = SpecDir.new(spec_root_path, '/specs')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#get" do
|
|
16
|
+
attr_reader :html, :doc
|
|
17
|
+
before do
|
|
18
|
+
request = request('get', '/specs')
|
|
19
|
+
response = Rack::Response.new
|
|
20
|
+
dir.get(request, response)
|
|
21
|
+
@html = response.body
|
|
22
|
+
@doc = Hpricot(html)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "returns script tags for each test javascript file" do
|
|
26
|
+
doc.at("script[@src='/specs/failing_spec.js']").should exist
|
|
27
|
+
doc.at("script[@src='/specs/foo/failing_spec.js']").should exist
|
|
28
|
+
doc.at("script[@src='/specs/foo/passing_spec.js']").should exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "returns the screw unit template" do
|
|
32
|
+
doc.at("link[@href='/core/screw.css']").should exist
|
|
33
|
+
doc.at("script[@src='/core/screw.builder.js']").should exist
|
|
34
|
+
doc.at("script[@src='/core/screw.events.js']").should exist
|
|
35
|
+
doc.at("script[@src='/core/screw.behaviors.js']").should exist
|
|
36
|
+
doc.at("script[@src='/core/screw.assets.js']").should exist
|
|
37
|
+
doc.at("body/#screw_unit_content").should_not be_nil
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
|
2
|
+
|
|
3
|
+
module JsTestCore
|
|
4
|
+
module Resources
|
|
5
|
+
module Specs
|
|
6
|
+
describe SpecFile do
|
|
7
|
+
describe "#spec_files" do
|
|
8
|
+
attr_reader :absolute_path, :relative_path, :file
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
@absolute_path = "#{spec_root_path}/failing_spec.js"
|
|
12
|
+
@relative_path = "/specs/failing_spec.js"
|
|
13
|
+
@file = SpecFile.new(absolute_path, relative_path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#get" do
|
|
17
|
+
attr_reader :html, :doc
|
|
18
|
+
before do
|
|
19
|
+
request = request('get', '/specs')
|
|
20
|
+
response = Rack::Response.new
|
|
21
|
+
file.get(request, response)
|
|
22
|
+
@html = response.body
|
|
23
|
+
@doc = Hpricot(html)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "returns script tags for the test javascript file" do
|
|
27
|
+
doc.at("script[@src='/specs/failing_spec.js']").should exist
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "returns the screw unit template" do
|
|
31
|
+
doc.at("link[@href='/core/screw.css']").should exist
|
|
32
|
+
doc.at("script[@src='/core/screw.builder.js']").should exist
|
|
33
|
+
doc.at("script[@src='/core/screw.events.js']").should exist
|
|
34
|
+
doc.at("script[@src='/core/screw.behaviors.js']").should exist
|
|
35
|
+
doc.at("script[@src='/core/screw.assets.js']").should exist
|
|
36
|
+
doc.at("body/#screw_unit_content").should_not be_nil
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "spec"
|
|
3
|
+
dir = File.dirname(__FILE__)
|
|
4
|
+
|
|
5
|
+
$LOAD_PATH.unshift "#{dir}/../../lib"
|
|
6
|
+
require "screw_unit"
|
|
7
|
+
require "hpricot"
|
|
8
|
+
require "guid"
|
|
9
|
+
|
|
10
|
+
Spec::Runner.configure do |config|
|
|
11
|
+
config.mock_with :rr
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Spec
|
|
15
|
+
module Matchers
|
|
16
|
+
class Exist
|
|
17
|
+
def matches?(actual)
|
|
18
|
+
@actual = actual
|
|
19
|
+
!@actual.nil?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Spec::Example::ExampleGroup
|
|
26
|
+
class << self
|
|
27
|
+
def thin_logging
|
|
28
|
+
@thin_logging = true if @thin_logging.nil?
|
|
29
|
+
@thin_logging
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
attr_writer :thin_logging
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
module Spec::Example::ExampleMethods
|
|
37
|
+
attr_reader :spec_root_path, :implementation_root_path, :public_path, :server, :connection
|
|
38
|
+
before(:all) do
|
|
39
|
+
dir = File.dirname(__FILE__)
|
|
40
|
+
@spec_root_path = File.expand_path("#{dir}/../example_specs")
|
|
41
|
+
@implementation_root_path = File.expand_path("#{dir}/../example_public/javascripts")
|
|
42
|
+
@public_path = File.expand_path("#{dir}/../example_public")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
before(:each) do
|
|
46
|
+
JsTestCore::Server.instance = JsTestCore::Server.new(spec_root_path, implementation_root_path, public_path)
|
|
47
|
+
stub(EventMachine).run do
|
|
48
|
+
raise "You need to mock calls to EventMachine.run or the process will hang"
|
|
49
|
+
end
|
|
50
|
+
stub(EventMachine).start_server do
|
|
51
|
+
raise "You need to mock calls to EventMachine.start_server or the process will hang"
|
|
52
|
+
end
|
|
53
|
+
stub(EventMachine).send_data do
|
|
54
|
+
raise "Calls to EventMachine.send_data must be mocked or stubbed"
|
|
55
|
+
end
|
|
56
|
+
@connection = Thin::JsTestCoreConnection.new(Guid.new)
|
|
57
|
+
stub(EventMachine).send_data {raise "EventMachine.send_data must be handled"}
|
|
58
|
+
stub(EventMachine).close_connection {raise "EventMachine.close_connection must be handled"}
|
|
59
|
+
@server = JsTestCore::Server.instance
|
|
60
|
+
Thin::Logging.silent = !self.class.thin_logging
|
|
61
|
+
Thin::Logging.debug = self.class.thin_logging
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
after(:each) do
|
|
65
|
+
Thin::Logging.silent = true
|
|
66
|
+
Thin::Logging.debug = false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def get(url, params={})
|
|
70
|
+
request(:get, url, params)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def post(url, params={})
|
|
74
|
+
request(:post, url, params)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def put(url, params={})
|
|
78
|
+
request(:put, url, params)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def delete(url, params={})
|
|
82
|
+
request(:delete, url, params)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def env_for(method, url, params)
|
|
86
|
+
Rack::MockRequest.env_for(url, params.merge({:method => method.to_s.upcase, 'js_test_core.connection' => connection}))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def create_request(method, url, params={})
|
|
90
|
+
env = env_for(method, url, params)
|
|
91
|
+
server.call(env)[2]
|
|
92
|
+
end
|
|
93
|
+
alias_method :request, :create_request
|
|
94
|
+
|
|
95
|
+
def core_path
|
|
96
|
+
JsTestCore::Server.core_path
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def spec_file(relative_path)
|
|
100
|
+
absolute_path = spec_root_path + relative_path
|
|
101
|
+
JsTestCore::Resources::File.new(absolute_path, "/specs#{relative_path}")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def spec_dir(relative_path="")
|
|
105
|
+
absolute_path = spec_root_path + relative_path
|
|
106
|
+
JsTestCore::Resources::SpecDir.new(absolute_path, "/specs#{relative_path}")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def contain_spec_file_with_correct_paths(path_relative_to_spec_root)
|
|
110
|
+
expected_absolute_path = spec_root_path + path_relative_to_spec_root
|
|
111
|
+
expected_relative_path = "/specs" + path_relative_to_spec_root
|
|
112
|
+
|
|
113
|
+
::Spec::Matchers::SimpleMatcher.new(expected_relative_path) do |globbed_files|
|
|
114
|
+
file = globbed_files.find do |file|
|
|
115
|
+
file.absolute_path == expected_absolute_path
|
|
116
|
+
end
|
|
117
|
+
file && file.relative_path == expected_relative_path
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
data/spec/unit_suite.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
0.1.1
|
|
2
|
+
- SuiteFinish#post immediately closes the connection
|
|
3
|
+
|
|
4
|
+
0.1.0
|
|
5
|
+
- Initial Release extracted from JsTestCore.
|
|
6
|
+
- Added JsTestCore::WebRoot.dispatch_specs and .dispatch_strategy
|
|
7
|
+
- Extracted JsTestCore::Resources::Specs::SpecDir
|
|
8
|
+
- Extracted JsTestCore::Resources::Specs::SpecFile
|
|
9
|
+
- No longer depending on Guid. The child libraries are responsible for obtaining the Selenium session_id from the client by using top.runOptions.getSessionId().
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
= JsTestCore
|
|
2
|
+
The JsTestCore library is the core javascript test server library used by several JS Test server libraries.
|
|
3
|
+
|
|
4
|
+
To hook up your own JS Test framework:
|
|
5
|
+
* You will need to call either JsTestCore::Resources::WebRoot.dispatch_specs or JsTestCore::Resources::WebRoot.dispatch_tests
|
|
6
|
+
depending if you are serving specs or tests.
|
|
7
|
+
* Set JsTestCore.core_path to the directory of the client side test framework (javascript files)
|
|
8
|
+
* Override JsTestCore::Resources::Specs::SpecFile#get or JsTestCore::Resources::Specs::TestFile#get
|
|
9
|
+
* Override JsTestCore::Resources::Specs::SpecDir#get or JsTestCore::Resources::Specs::TestDir#get
|
|
10
|
+
|
|
11
|
+
NOTE: The current version of JsTestCore does not yet support tests. Support will be added soon.
|
|
12
|
+
I just wanted the test stuff to be in the docs to establish the current architectural direction.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require "rake"
|
|
2
|
+
require 'rake/gempackagetask'
|
|
3
|
+
require 'rake/contrib/rubyforgepublisher'
|
|
4
|
+
require 'rake/clean'
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
require 'rake/rdoctask'
|
|
7
|
+
|
|
8
|
+
desc "Runs the Rspec suite"
|
|
9
|
+
task(:default) do
|
|
10
|
+
run_suite
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Runs the Rspec suite"
|
|
14
|
+
task(:spec) do
|
|
15
|
+
run_suite
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Copies the trunk to a tag with the name of the current release"
|
|
19
|
+
task(:tag_release) do
|
|
20
|
+
tag_release
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def run_suite
|
|
24
|
+
dir = File.dirname(__FILE__)
|
|
25
|
+
system("ruby #{dir}/spec/spec_suite.rb") || raise("Example Suite failed")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
PKG_NAME = "js_test_core"
|
|
29
|
+
PKG_VERSION = "0.1.1"
|
|
30
|
+
PKG_FILES = FileList[
|
|
31
|
+
'[A-Z]*',
|
|
32
|
+
'*.rb',
|
|
33
|
+
'lib/**/*.rb',
|
|
34
|
+
'core/**',
|
|
35
|
+
'bin/**',
|
|
36
|
+
'spec/**/*.rb'
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
spec = Gem::Specification.new do |s|
|
|
40
|
+
s.name = PKG_NAME
|
|
41
|
+
s.version = PKG_VERSION
|
|
42
|
+
s.summary = "The JsTestCore library is the core javascript test server library used by several JS Test server libraries."
|
|
43
|
+
s.test_files = "spec/spec_suite.rb"
|
|
44
|
+
s.description = s.summary
|
|
45
|
+
|
|
46
|
+
s.files = PKG_FILES.to_a
|
|
47
|
+
s.require_path = 'lib'
|
|
48
|
+
|
|
49
|
+
s.has_rdoc = true
|
|
50
|
+
s.extra_rdoc_files = [ "README", "CHANGES" ]
|
|
51
|
+
s.rdoc_options = ["--main", "README", "--inline-source", "--line-numbers"]
|
|
52
|
+
|
|
53
|
+
s.test_files = Dir.glob('spec/*_spec.rb')
|
|
54
|
+
s.require_path = 'lib'
|
|
55
|
+
s.author = "Brian Takita"
|
|
56
|
+
s.email = "brian@pivotallabs.com"
|
|
57
|
+
s.homepage = "http://pivotallabs.com"
|
|
58
|
+
s.rubyforge_project = "pivotalrb"
|
|
59
|
+
s.add_dependency('Selenium')
|
|
60
|
+
s.add_dependency('thin', '=0.8.1')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
|
64
|
+
pkg.need_zip = true
|
|
65
|
+
pkg.need_tar = true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def tag_release
|
|
69
|
+
dashed_version = PKG_VERSION.gsub('.', '-')
|
|
70
|
+
svn_user = "#{ENV["SVN_USER"]}@" || ""
|
|
71
|
+
`svn cp svn+ssh://#{svn_user}rubyforge.org/var/svn/pivotalrb/js_test_core/trunk svn+ssh://#{svn_user}rubyforge.org/var/svn/pivotalrb/js_test_core/tags/REL-#{dashed_version} -m 'Version #{PKG_VERSION}'`
|
|
72
|
+
end
|