screw-unit 0.3.3 → 0.5.1
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 +10 -0
- data/Rakefile +27 -25
- data/VERSION.yml +4 -0
- data/bin/screw_unit_server +14 -4
- data/core/EXAMPLE.html +1 -1
- data/core/example/spec/suite.html +1 -1
- data/core/lib/jquery-1.3.2.js +4376 -0
- data/core/lib/jquery.fn.js +2 -1
- data/core/lib/screw.behaviors.js +8 -7
- data/core/lib/screw.builder.js +34 -19
- data/core/lib/screw.css +1 -1
- data/core/lib/screw.events.js +5 -5
- data/core/lib/screw.matchers.js +59 -2
- data/core/spec/suite.html +2 -1
- data/core/spec/with_screw_context_spec.js +9 -0
- data/lib/screw_unit.rb +13 -16
- data/lib/screw_unit/representations.rb +2 -0
- data/lib/screw_unit/{resources/spec.rb → representations/spec.html.rb} +55 -39
- data/spec/functional/functional_spec.rb +1 -1
- data/spec/functional/functional_spec_helper.rb +21 -33
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +52 -18
- data/spec/unit/unit_spec_helper.rb +24 -91
- data/vendor/js-test-core/CHANGES +8 -0
- data/vendor/js-test-core/Rakefile +1 -0
- data/vendor/js-test-core/lib/js_test_core.rb +22 -14
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +21 -9
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
- 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/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 +13 -7
- 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 +42 -20
- 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 +5 -60
- data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -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/foo/failing_spec.js +1 -1
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
- 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/unit/js_test_core/client_spec.rb +35 -10
- 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 +54 -63
- 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 +15 -19
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -149
- 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/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
- metadata +134 -145
- data/core/lib/jquery-1.2.6.js +0 -3549
- data/lib/screw_unit/resources.rb +0 -2
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -38
- data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
- data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -67
- data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -11
- data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
- data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
- data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -46
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/server.rb +0 -50
- data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
- data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
- data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -8
- data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
- data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -52
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -105
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -117
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
- data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -9
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -116
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource.rb +0 -108
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource_invalid.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -207
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resource_spec.rb +0 -127
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -124
data/lib/screw_unit/resources.rb
DELETED
@@ -1,38 +0,0 @@
|
|
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
|
-
|
8
|
-
describe "GET /specs" do
|
9
|
-
attr_reader :dir, :html, :doc
|
10
|
-
|
11
|
-
before do
|
12
|
-
mock(connection).send_head
|
13
|
-
mock(connection).send_body(anything) do |@html|
|
14
|
-
# do nothing
|
15
|
-
end
|
16
|
-
|
17
|
-
connection.receive_data("GET /specs HTTP/1.1\r\nHost: _\r\n\r\n")
|
18
|
-
@doc = Hpricot(html)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns script tags for each test javascript file" do
|
22
|
-
doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
|
23
|
-
doc.at("script[@src='/specs/foo/failing_spec.js']").should_not be_nil
|
24
|
-
doc.at("script[@src='/specs/foo/passing_spec.js']").should_not be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns the screw unit template" do
|
28
|
-
doc.at("link[@href='/core/screw.css']").should_not be_nil
|
29
|
-
doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
|
30
|
-
doc.at("script[@src='/core/screw.events.js']").should_not be_nil
|
31
|
-
doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
|
32
|
-
doc.at("body/#screw_unit_content").should_not be_nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
class RailsServer < Server
|
3
|
-
class << self
|
4
|
-
def run(rails_root, server_options = {})
|
5
|
-
server_options[:Host] ||= DEFAULT_HOST
|
6
|
-
server_options[:Port] ||= DEFAULT_PORT
|
7
|
-
Server.instance = new(rails_root, server_options[:Host], server_options[:Port])
|
8
|
-
Server.instance.run server_options
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(rails_root, host=DEFAULT_HOST, port=DEFAULT_PORT)
|
13
|
-
super(
|
14
|
-
"#{rails_root}/spec/javascripts",
|
15
|
-
"#{rails_root}/public/javascripts",
|
16
|
-
"#{rails_root}/public",
|
17
|
-
host,
|
18
|
-
port
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Dir < File
|
4
|
-
route ANY do |env, name|
|
5
|
-
if file = file(name)
|
6
|
-
file
|
7
|
-
elsif subdir = subdir(name)
|
8
|
-
subdir
|
9
|
-
else
|
10
|
-
FileNotFound.new(env.merge(:name => name))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def get
|
15
|
-
connection.send_head
|
16
|
-
connection.send_body(::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
|
17
|
-
file_basename = ::File.basename(file)
|
18
|
-
html << %Q|<a href="#{file_basename}">#{file_basename}</a>\n|
|
19
|
-
end)
|
20
|
-
end
|
21
|
-
|
22
|
-
def glob(pattern)
|
23
|
-
expanded_pattern = absolute_path + pattern
|
24
|
-
::Dir.glob(expanded_pattern).map do |absolute_globbed_path|
|
25
|
-
relative_globbed_path = absolute_globbed_path.gsub(absolute_path, relative_path)
|
26
|
-
File.new(env.merge(
|
27
|
-
:absolute_path => absolute_globbed_path,
|
28
|
-
:relative_path => relative_globbed_path
|
29
|
-
))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
protected
|
34
|
-
def determine_child_paths(name)
|
35
|
-
absolute_child_path = "#{absolute_path}/#{name}"
|
36
|
-
relative_child_path = "#{relative_path}/#{name}"
|
37
|
-
[absolute_child_path, relative_child_path]
|
38
|
-
end
|
39
|
-
|
40
|
-
def file(name)
|
41
|
-
# N.B. Absolute_path and relative_path are methods. Do not shadow.
|
42
|
-
absolute_file_path, relative_file_path = determine_child_paths(name)
|
43
|
-
if ::File.exists?(absolute_file_path) && !::File.directory?(absolute_file_path)
|
44
|
-
Resources::File.new(env.merge(
|
45
|
-
:absolute_path => absolute_file_path,
|
46
|
-
:relative_path => relative_file_path
|
47
|
-
))
|
48
|
-
else
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def subdir(name)
|
54
|
-
# N.B. Absolute_path and relative_path are methods. Do not shadow.
|
55
|
-
absolute_dir_path, relative_dir_path = determine_child_paths(name)
|
56
|
-
if ::File.directory?(absolute_dir_path)
|
57
|
-
Resources::Dir.new(env.merge(
|
58
|
-
:absolute_path => absolute_dir_path,
|
59
|
-
:relative_path => relative_dir_path
|
60
|
-
))
|
61
|
-
else
|
62
|
-
nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Runner < ThinRest::Resource
|
4
|
-
class Collection < ThinRest::Resource
|
5
|
-
property :selenium_browser_start_command
|
6
|
-
route 'firefox' do |env, name|
|
7
|
-
self.selenium_browser_start_command = "*firefox"
|
8
|
-
self
|
9
|
-
end
|
10
|
-
route 'iexplore' do |env, name|
|
11
|
-
self.selenium_browser_start_command = "*iexplore"
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
def after_initialize
|
16
|
-
super
|
17
|
-
self.selenium_browser_start_command = rack_request['selenium_browser_start_command']
|
18
|
-
end
|
19
|
-
|
20
|
-
def post
|
21
|
-
spec_url = rack_request['spec_url'].to_s == "" ? full_spec_suite_url : rack_request['spec_url']
|
22
|
-
parsed_spec_url = URI.parse(spec_url)
|
23
|
-
selenium_host = rack_request['selenium_host'].to_s == "" ? 'localhost' : rack_request['selenium_host'].to_s
|
24
|
-
selenium_port = rack_request['selenium_port'].to_s == "" ? 4444 : Integer(rack_request['selenium_port'])
|
25
|
-
http_address = "#{parsed_spec_url.scheme}://#{parsed_spec_url.host}:#{parsed_spec_url.port}"
|
26
|
-
driver = Selenium::SeleniumDriver.new(
|
27
|
-
selenium_host,
|
28
|
-
selenium_port,
|
29
|
-
selenium_browser_start_command,
|
30
|
-
http_address
|
31
|
-
)
|
32
|
-
begin
|
33
|
-
driver.start
|
34
|
-
rescue Errno::ECONNREFUSED => e
|
35
|
-
raise Errno::ECONNREFUSED, "Cannot connect to Selenium Server at #{http_address}. To start the selenium server, run `selenium`."
|
36
|
-
end
|
37
|
-
runner = Runner.new(:driver => driver)
|
38
|
-
Runner.register(runner)
|
39
|
-
Thread.start do
|
40
|
-
driver.open("/")
|
41
|
-
driver.create_cookie("session_id=#{runner.session_id}")
|
42
|
-
driver.open(parsed_spec_url.path)
|
43
|
-
end
|
44
|
-
connection.send_head
|
45
|
-
connection.send_body("session_id=#{runner.session_id}")
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
def full_spec_suite_url
|
50
|
-
"#{Server.root_url}/specs"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class << self
|
55
|
-
def find(id)
|
56
|
-
instances[id.to_s]
|
57
|
-
end
|
58
|
-
|
59
|
-
def finalize(session_id, text)
|
60
|
-
if runner = find(session_id)
|
61
|
-
runner.finalize(text)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def register(runner)
|
66
|
-
instances[runner.session_id] = runner
|
67
|
-
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
def instances
|
71
|
-
@instances ||= {}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
include FileUtils
|
76
|
-
property :driver
|
77
|
-
attr_reader :profile_dir, :session_run_result
|
78
|
-
|
79
|
-
def after_initialize
|
80
|
-
profile_base = "#{::Dir.tmpdir}/js_test_core/#{self.class.name}"
|
81
|
-
mkdir_p profile_base
|
82
|
-
@profile_dir = "#{profile_base}/#{Time.now.to_i}"
|
83
|
-
end
|
84
|
-
|
85
|
-
def finalize(session_run_result)
|
86
|
-
driver.stop
|
87
|
-
@session_run_result = session_run_result.to_s
|
88
|
-
end
|
89
|
-
|
90
|
-
def running?
|
91
|
-
driver.session_started?
|
92
|
-
end
|
93
|
-
|
94
|
-
def successful?
|
95
|
-
!running? && session_run_result.empty?
|
96
|
-
end
|
97
|
-
|
98
|
-
def failed?
|
99
|
-
!running? && !successful?
|
100
|
-
end
|
101
|
-
|
102
|
-
def session_id
|
103
|
-
driver.session_id
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Session < ThinRest::Resource
|
4
|
-
class Collection < ThinRest::Resource
|
5
|
-
route ANY do |env, id|
|
6
|
-
Session.new(env.merge(:id => id))
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
RUNNING = 'running'
|
11
|
-
SUCCESSFUL_COMPLETION = 'success'
|
12
|
-
FAILURE_COMPLETION = 'failure'
|
13
|
-
|
14
|
-
property :id
|
15
|
-
|
16
|
-
def get
|
17
|
-
runner = Runner.find(id)
|
18
|
-
if runner
|
19
|
-
connection.send_head
|
20
|
-
if runner.running?
|
21
|
-
connection.send_body("status=#{RUNNING}")
|
22
|
-
else
|
23
|
-
if runner.successful?
|
24
|
-
connection.send_body("status=#{SUCCESSFUL_COMPLETION}")
|
25
|
-
else
|
26
|
-
connection.send_body("status=#{FAILURE_COMPLETION}&reason=#{runner.session_run_result}")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
else
|
30
|
-
connection.send_head(404)
|
31
|
-
connection.send_body("")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
route 'finish' do |env, name|
|
36
|
-
SessionFinish.new(env.merge(:session => self))
|
37
|
-
end
|
38
|
-
|
39
|
-
def associated_with_a_runner?
|
40
|
-
id.to_s != ""
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class SessionFinish < ThinRest::Resource
|
4
|
-
property :session
|
5
|
-
|
6
|
-
def post
|
7
|
-
if session.associated_with_a_runner?
|
8
|
-
Runner.finalize(session.id, rack_request['text'])
|
9
|
-
else
|
10
|
-
STDOUT.puts rack_request['text']
|
11
|
-
end
|
12
|
-
connection.send_head
|
13
|
-
connection.send_body("")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
module Specs
|
4
|
-
class SpecDirSuperclass < ::JsTestCore::Resources::Dir
|
5
|
-
def get
|
6
|
-
raise NotImplementedError, "#{self.class}#get needs to be implemented"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class SpecDir < SpecDirSuperclass
|
11
|
-
def spec_files
|
12
|
-
glob("/**/*_spec.js")
|
13
|
-
end
|
14
|
-
|
15
|
-
route ANY do |env, name|
|
16
|
-
if result = (file(name) || subdir(name) || spec_file(name))
|
17
|
-
result
|
18
|
-
else
|
19
|
-
base_path = "#{relative_path}/#{name}"
|
20
|
-
raise "No file or directory found at #{base_path} or spec found at #{base_path}.js."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def subdir(name)
|
27
|
-
absolute_path, relative_path = determine_child_paths(name)
|
28
|
-
if ::File.directory?(absolute_path)
|
29
|
-
SpecDir.new(env.merge(:absolute_path => absolute_path, :relative_path => relative_path))
|
30
|
-
else
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def spec_file(name)
|
36
|
-
absolute_path, relative_path = determine_child_paths("#{name}.js")
|
37
|
-
if ::File.exists?(absolute_path) && !::File.directory?(absolute_path)
|
38
|
-
SpecFile.new(env.merge(:absolute_path => absolute_path, :relative_path => relative_path))
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
module Specs
|
4
|
-
class SpecFileSuperclass < ::JsTestCore::Resources::File
|
5
|
-
def get
|
6
|
-
raise NotImplementedError, "#{self.class}#get needs to be implemented"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class SpecFile < SpecFileSuperclass
|
11
|
-
def spec_files
|
12
|
-
[self]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,50 +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 request; instance.request; end
|
18
|
-
def response; instance.response; end
|
19
|
-
def root_url; instance.root_url; end
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :host, :port, :spec_root_path, :implementation_root_path, :public_path
|
23
|
-
|
24
|
-
def initialize(spec_root_path, implementation_root_path, public_path, host=DEFAULT_HOST, port=DEFAULT_PORT)
|
25
|
-
dir = ::File.dirname(__FILE__)
|
26
|
-
@spec_root_path = ::File.expand_path(spec_root_path)
|
27
|
-
@implementation_root_path = ::File.expand_path(implementation_root_path)
|
28
|
-
@public_path = ::File.expand_path(public_path)
|
29
|
-
@host = host
|
30
|
-
@port = port
|
31
|
-
end
|
32
|
-
|
33
|
-
def run(options)
|
34
|
-
server = ::Thin::Server.new(options[:Host], options[:Port]) do
|
35
|
-
use Rack::CommonLogger
|
36
|
-
end
|
37
|
-
server.backend = ::Thin::Backends::JsTestCoreServer.new(options[:Host], options[:Port])
|
38
|
-
server.backend.server = server
|
39
|
-
server.start!
|
40
|
-
end
|
41
|
-
|
42
|
-
def root_url
|
43
|
-
"http://#{host}:#{port}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def core_path
|
47
|
-
JsTestCore.core_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|