qunited 0.2.1 → 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/lib/qunited/rake_task.rb +19 -0
- data/lib/qunited/server/qunit.css +236 -0
- data/lib/qunited/server/qunit.js +1838 -0
- data/lib/qunited/server/test_suite.html.erb +24 -0
- data/lib/qunited/server.rb +81 -0
- data/lib/qunited/version.rb +1 -1
- data/lib/qunited.rb +1 -0
- metadata +9 -5
@@ -0,0 +1,24 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>QUnit Test Suite</title>
|
5
|
+
<%= asset_css_tag 'qunit.css' %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1 id="qunit-header">QUnit Test Suite</h1>
|
9
|
+
<h2 id="qunit-banner"></h2>
|
10
|
+
<div id="qunit-testrunner-toolbar"></div>
|
11
|
+
<h2 id="qunit-userAgent"></h2>
|
12
|
+
<ol id="qunit-tests"></ol>
|
13
|
+
</body>
|
14
|
+
<%= asset_script_tag 'qunit.js' %>
|
15
|
+
|
16
|
+
<% source_files.each do |file| %>
|
17
|
+
<%= source_script_tag file %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<% test_files.each do |file| %>
|
21
|
+
<%= test_script_tag file %>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
</html>
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'erb'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module QUnited
|
6
|
+
class Server
|
7
|
+
DEFAULT_PORT = 3040
|
8
|
+
|
9
|
+
ASSETS_PATH = File.expand_path('../server', __FILE__)
|
10
|
+
|
11
|
+
SOURCE_FILE_PREFIX = 'qunited-source-file'
|
12
|
+
TEST_FILE_PREFIX = 'qunited-test-file'
|
13
|
+
|
14
|
+
QUNITED_ASSET_FILE_PREFIX = 'qunited-asset'
|
15
|
+
|
16
|
+
attr_accessor :source_files, :test_files
|
17
|
+
|
18
|
+
def initialize(opts={})
|
19
|
+
@source_files, @test_files = opts[:source_files], opts[:test_files]
|
20
|
+
|
21
|
+
server_options = {
|
22
|
+
:Port => opts[:port] || DEFAULT_PORT
|
23
|
+
}
|
24
|
+
|
25
|
+
@server = ::WEBrick::HTTPServer.new(server_options)
|
26
|
+
|
27
|
+
@server.mount_proc '/' do |request, response|
|
28
|
+
response.status = 200
|
29
|
+
|
30
|
+
case request.path
|
31
|
+
when /^\/#{SOURCE_FILE_PREFIX}\/(.*)/, /^\/#{TEST_FILE_PREFIX}\/(.*)/
|
32
|
+
response['Content-Type'] = 'application/javascript'
|
33
|
+
response.body = IO.read($1)
|
34
|
+
when /^\/#{QUNITED_ASSET_FILE_PREFIX}\/(.*)/
|
35
|
+
filename = $1
|
36
|
+
response['Content-Type'] = (filename =~ /\.js$/) ? 'application/javascript' : 'text/css'
|
37
|
+
puts "HUH? #{filename}"
|
38
|
+
response.body = IO.read(asset_path filename)
|
39
|
+
else
|
40
|
+
response['Content-Type'] = 'text/html'
|
41
|
+
test_suite_template = ::ERB.new(IO.read(asset_path 'test_suite.html.erb'))
|
42
|
+
response.body = test_suite_template.result(binding)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
['INT', 'TERM'].each do |signal|
|
47
|
+
trap(signal) { @server.shutdown }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def start
|
52
|
+
@server.start
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def asset_path(filename)
|
58
|
+
File.join(ASSETS_PATH, filename)
|
59
|
+
end
|
60
|
+
|
61
|
+
def source_script_tag(file_path)
|
62
|
+
script_tag "#{SOURCE_FILE_PREFIX}/#{file_path}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_script_tag(file_path)
|
66
|
+
script_tag "#{TEST_FILE_PREFIX}/#{file_path}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def asset_script_tag(filename)
|
70
|
+
script_tag "#{QUNITED_ASSET_FILE_PREFIX}/#{filename}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def asset_css_tag(filename)
|
74
|
+
%{<link rel="stylesheet" type="text/css" href="#{QUNITED_ASSET_FILE_PREFIX}/#{filename}">}
|
75
|
+
end
|
76
|
+
|
77
|
+
def script_tag(src)
|
78
|
+
%{<script type="text/javascript" src="#{src}"></script>}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/qunited/version.rb
CHANGED
data/lib/qunited.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qunited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aaron Royer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-12-
|
18
|
+
date: 2012-12-17 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: QUnited runs headless QUnit tests as part of your normal build
|
@@ -50,6 +50,10 @@ files:
|
|
50
50
|
- lib/qunited/rake_task.rb
|
51
51
|
- lib/qunited/results.rb
|
52
52
|
- lib/qunited/runner.rb
|
53
|
+
- lib/qunited/server.rb
|
54
|
+
- lib/qunited/server/qunit.css
|
55
|
+
- lib/qunited/server/qunit.js
|
56
|
+
- lib/qunited/server/test_suite.html.erb
|
53
57
|
- lib/qunited/version.rb
|
54
58
|
- qunited.gemspec
|
55
59
|
- test/fixtures/basic_project/app/assets/javascripts/application.js
|