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,3 +1,22 @@
1
+ - No longer using the /implementanions directory. Replace all cases of /implementations with /javascripts.
2
+ - Added support for custom suite files
3
+ - Added dependency on Erector
4
+ - Better error messages
5
+ - Changed dependency from Selenium to selenium-client
6
+ - Renamed Resources::Runner to Resources::SeleniumSession
7
+ - Changed /runners to /selenium_sessions
8
+
9
+ 0.2.0
10
+ - Renamed Suite to Session to follow Selenium conventions
11
+ - Renamed SuiteFinish to SessionFinish to follow Selenium conventions
12
+ - Added /session, which uses the session_id cookie to derive the current session.
13
+ - Added /session/finished to be used to simplify client/server interactions.
14
+ - Remove File caching because it doesn't cause a noticable performance benefit over a local network and because it sometimes doesn't write over stale files.
15
+ - Client accepts selenium_browser_start_command parameter, which allows the user to parameterize the selenium_browser_start_command
16
+ - Added support for running specs in Internet Explorer via POST /runners/iexplore
17
+ - Resource file download performance improvements via caching and chunked sending
18
+ - Fixed false positive bug when Client connection times out
19
+
1
20
  0.1.1
2
21
  - SuiteFinish#post immediately closes the connection
3
22
 
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "js_test_core"
29
- PKG_VERSION = "0.1.1"
29
+ PKG_VERSION = "0.2.0"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -58,6 +58,7 @@ spec = Gem::Specification.new do |s|
58
58
  s.rubyforge_project = "pivotalrb"
59
59
  s.add_dependency('Selenium')
60
60
  s.add_dependency('thin', '=0.8.1')
61
+ s.add_dependency('erector')
61
62
  end
62
63
 
63
64
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -1,30 +1,46 @@
1
1
  require "rubygems"
2
- gem "thin", ">=0.8.0"
2
+ gem "thin", ">=1.2.1"
3
+ gem "erector", ">=0.6.6"
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"
3
9
 
4
- require "thin"
5
10
  require "fileutils"
6
11
  require "tmpdir"
7
12
  require "timeout"
8
13
  require "cgi"
9
14
  require "net/http"
10
- require "selenium"
15
+ require "selenium/client"
11
16
  require "optparse"
17
+ require "erector"
12
18
 
13
- dir = File.dirname(__FILE__)
14
- require "#{dir}/js_test_core/thin"
15
- require "#{dir}/js_test_core/rack"
19
+ require "#{dir}/js_test_core/configuration"
20
+
21
+ require "#{dir}/js_test_core/extensions"
22
+ require "#{dir}/js_test_core/models"
16
23
  require "#{dir}/js_test_core/resources"
17
- require "#{dir}/js_test_core/selenium"
24
+ require "#{dir}/js_test_core/representations"
18
25
 
19
26
  require "#{dir}/js_test_core/client"
20
- require "#{dir}/js_test_core/server"
21
- require "#{dir}/js_test_core/rails_server"
27
+ require "#{dir}/js_test_core/selenium_server_configuration"
28
+
29
+ require "#{dir}/js_test_core/app"
22
30
 
23
31
  module JsTestCore
24
32
  DEFAULT_HOST = "0.0.0.0"
25
33
  DEFAULT_PORT = 8080
26
34
 
27
35
  class << self
28
- attr_accessor :core_path
36
+ Configuration.instance = Configuration.new
37
+
38
+ def method_missing(method_name, *args, &block)
39
+ if Configuration.instance.respond_to?(method_name)
40
+ Configuration.instance.send(method_name, *args, &block)
41
+ else
42
+ super
43
+ end
44
+ end
29
45
  end
30
46
  end
@@ -0,0 +1,12 @@
1
+ module JsTestCore
2
+ class App < Sinatra::Base
3
+ set :logging, true
4
+ register(JsTestCore::Resources::WebRoot.route_handler)
5
+ register(JsTestCore::Resources::SeleniumSession.route_handler)
6
+ register(JsTestCore::Resources::CoreFile.route_handler)
7
+ register(JsTestCore::Resources::SpecFile.route_handler)
8
+ register(JsTestCore::Resources::File.route_handler)
9
+ register(JsTestCore::Resources::ImplementationsDeprecation.route_handler)
10
+ register(JsTestCore::Resources::NotFound.route_handler)
11
+ end
12
+ end
@@ -1,24 +1,17 @@
1
1
  module JsTestCore
2
2
  class Client
3
- class << self
4
- def run(params={})
5
- data = []
6
- data << "selenium_host=#{CGI.escape(params[:selenium_host] || 'localhost')}"
7
- data << "selenium_port=#{CGI.escape((params[:selenium_port] || 4444).to_s)}"
8
- data << "spec_url=#{CGI.escape(params[:spec_url])}" if params[:spec_url]
9
- response = Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT) do |http|
10
- http.post('/runners/firefox', data.join("&"))
11
- end
3
+ class ClientException < Exception
4
+ end
12
5
 
13
- body = response.body
14
- if body.empty?
15
- puts "SUCCESS"
16
- return true
17
- else
18
- puts "FAILURE"
19
- puts body
20
- return false
21
- end
6
+ class InvalidStatusResponse < ClientException
7
+ end
8
+
9
+ class SessionNotFound < ClientException
10
+ end
11
+
12
+ class << self
13
+ def run(parameters={})
14
+ new(parameters).run
22
15
  end
23
16
 
24
17
  def run_argv(argv)
@@ -28,6 +21,10 @@ module JsTestCore
28
21
  o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]"
29
22
 
30
23
  o.on
24
+ o.on('-s', '--selenium_browser_start_command=selenium_browser_start_command', "The Selenium server command to start the browser. See http://selenium-rc.openqa.org/") do |selenium_browser_start_command|
25
+ params[:selenium_browser_start_command] = selenium_browser_start_command
26
+ end
27
+
31
28
  o.on('-h', '--selenium_host=SELENIUM_HOST', "The host name of the Selenium Server relative to where this file is executed") do |host|
32
29
  params[:selenium_host] = host
33
30
  end
@@ -40,11 +37,93 @@ module JsTestCore
40
37
  params[:spec_url] = spec_url
41
38
  end
42
39
 
40
+ o.on('-t', '--timeout=TIMEOUT', "The timeout limit of the test run") do |timeout|
41
+ params[:timeout] = Integer(timeout)
42
+ end
43
+
43
44
  o.on_tail
44
45
  end
45
46
  parser.order!(argv)
46
47
  run params
47
48
  end
48
49
  end
50
+
51
+ attr_reader :parameters, :query_string, :http, :session_start_response, :last_poll_status, :last_poll_reason, :last_poll
52
+ def initialize(parameters)
53
+ @parameters = parameters
54
+ @query_string = SeleniumServerConfiguration.query_string_from(parameters)
55
+ end
56
+
57
+ def run
58
+ if parameters[:timeout]
59
+ Timeout.timeout(parameters[:timeout]) {do_run}
60
+ else
61
+ do_run
62
+ end
63
+ end
64
+
65
+ def parts_from_query(query)
66
+ query.split('&').inject({}) do |acc, key_value_pair|
67
+ key, value = key_value_pair.split('=')
68
+ acc[key] = value
69
+ acc
70
+ end
71
+ end
72
+
73
+ protected
74
+ def do_run
75
+ Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT) do |@http|
76
+ start_runner
77
+ wait_for_session_to_finish
78
+ end
79
+ report_result
80
+ end
81
+
82
+ def start_runner
83
+ @session_start_response = http.post(Resources::SeleniumSession.path, query_string)
84
+ end
85
+
86
+ def wait_for_session_to_finish
87
+ while session_not_completed?
88
+ poll
89
+ sleep 0.25
90
+ end
91
+ end
92
+
93
+ def report_result
94
+ case last_poll_status
95
+ when Resources::SeleniumSession::SUCCESSFUL_COMPLETION
96
+ STDOUT.puts "SUCCESS"
97
+ true
98
+ when Resources::SeleniumSession::FAILURE_COMPLETION
99
+ STDOUT.puts "FAILURE"
100
+ STDOUT.puts last_poll_reason
101
+ false
102
+ else
103
+ raise InvalidStatusResponse, "Invalid Status: #{last_poll_status}"
104
+ end
105
+ end
106
+
107
+ def session_not_completed?
108
+ last_poll_status.nil? || last_poll_status == Resources::SeleniumSession::RUNNING
109
+ end
110
+
111
+ def poll
112
+ @last_poll = http.get(Resources::SeleniumSession.path("/:session_id", :session_id => session_id))
113
+ ensure_session_exists!
114
+ parts = parts_from_query(last_poll.body)
115
+ @last_poll_status = parts['status']
116
+ @last_poll_reason = parts['reason']
117
+ end
118
+
119
+ def ensure_session_exists!
120
+ if (400..499).include?(Integer(last_poll.code))
121
+ raise SessionNotFound, "Could not find session with id #{session_id}"
122
+ end
123
+ end
124
+
125
+ def session_id
126
+ @session_id ||= parts_from_query(session_start_response.body)['session_id']
127
+ end
49
128
  end
50
129
  end
@@ -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,3 @@
1
+ Dir["#{File.dirname(__FILE__)}/extensions/**/*.rb"].each do |file|
2
+ require file
3
+ end
@@ -0,0 +1,7 @@
1
+ module Selenium
2
+ module Client
3
+ Driver.class_eval do
4
+ attr_reader :session_id
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require "time"
2
+ class Time
3
+ def rfc822
4
+ strftime("%a, %d %b %Y %k:%M:%S %Z")
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ dir = File.dirname(__FILE__)
2
+
3
+ module JsTestCore
4
+ module Models
5
+ end
6
+ end
7
+
8
+ require "#{dir}/models/selenium_session"
@@ -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,15 @@
1
+ module JsTestCore
2
+ module Representations
3
+ class NotFound < Page
4
+ needs :message
5
+ protected
6
+ def body_content
7
+ h1 message
8
+ end
9
+
10
+ def title_text
11
+ message
12
+ end
13
+ end
14
+ end
15
+ end