akui 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bowerrc +5 -0
- data/.gitignore +21 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/README.md +43 -0
- data/VERSION +1 -0
- data/akui +0 -0
- data/akui.gemspec +38 -0
- data/bin/akui +10 -0
- data/lib/akui.rb +241 -0
- data/lib/browser/_index.html +26 -0
- data/lib/browser/akui/akui.js +53 -0
- data/lib/browser/favicon.ico +0 -0
- data/lib/browser/style.css +6 -0
- data/lib/browser/window.onerror.js +7 -0
- data/specs/0000-it-runs/spec.rb +88 -0
- data/specs/config.ru +36 -0
- data/specs/helpers.rb +4 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bd251f0e99f3f1dd669ea8d500f30f32a71a886e
|
4
|
+
data.tar.gz: 72ef2a7389575d1b2f3624540c685060a64c2495
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac1f3f89695f6a27abbc79d11cdbc556f9e80e60b114ca82cac36758eee2a8ee3e5f6d8f9f2e740065cba67cae994ebbc1fee2ba6a55916e27cf1def4170b8a9
|
7
|
+
data.tar.gz: dd8d327f496c56a04be1cc14d73fd5ee334d8c8678edb9e07a52e942137739850294315b83143252aa2934bae3ee8f42a41b97f5ad0327be4c35a1c082439c52
|
data/.bowerrc
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
Copyright (c) 2015 da99
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
Intro:
|
3
|
+
=====
|
4
|
+
|
5
|
+
A Ruby gem that helps me automate testing JS code on the browser.
|
6
|
+
It uses a Rack middleware to include JS testing code files
|
7
|
+
into the rendered HTML.
|
8
|
+
|
9
|
+
This is not useful to you. Instead, use the following for testing
|
10
|
+
stuff in the browser:
|
11
|
+
|
12
|
+
* [Bromine.js](http://cheggeng.github.io/Bromine/)
|
13
|
+
* [Karma (aka Testacular)](http://karma-runner.github.io/)
|
14
|
+
* [Casper.js](http://casperjs.org/)
|
15
|
+
* [Buster.js](http://busterjs.org/)
|
16
|
+
* [Watir](http://watir.com) <--- my favorite
|
17
|
+
* ... and a million other alternatives.
|
18
|
+
|
19
|
+
Dependencies
|
20
|
+
============
|
21
|
+
|
22
|
+
* jQuery >= 1.9.1+
|
23
|
+
* Underscore >= 1.4.3
|
24
|
+
* [Fermata](https://github.com/natevw/fermata) > 0.0.0
|
25
|
+
|
26
|
+
Install:
|
27
|
+
========
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem install akui
|
31
|
+
```
|
32
|
+
|
33
|
+
NOTE:
|
34
|
+
=====
|
35
|
+
|
36
|
+
This was originally a npm module.
|
37
|
+
That code is still available in the
|
38
|
+
[nodejs branch](https://github.com/da99/akui/tree/nodejs).
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/akui
ADDED
File without changes
|
data/akui.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "akui"
|
7
|
+
spec.version = `cat VERSION`
|
8
|
+
spec.authors = ["da99"]
|
9
|
+
spec.email = ["i-hate-spam-1234567@mailinator.com"]
|
10
|
+
spec.summary = %q{My way of testing browser/client-side code.}
|
11
|
+
spec.description = %q{
|
12
|
+
Automate testing code on the browser by using Rack
|
13
|
+
middleware to include JS testing code files
|
14
|
+
into your rendered HTML.
|
15
|
+
}
|
16
|
+
spec.homepage = "https://github.com/da99/akui"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |file|
|
20
|
+
file.index('bin/') == 0 && file != "bin/#{File.basename Dir.pwd}"
|
21
|
+
}
|
22
|
+
spec.executables = spec.files.grep("bin/#{spec.name}") { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.required_ruby_version = '>= 2.2.0'
|
27
|
+
|
28
|
+
spec.add_dependency "cuba", "> 3.3"
|
29
|
+
spec.add_dependency "escape_escape_escape", "> 1.4"
|
30
|
+
|
31
|
+
spec.add_development_dependency "pry" , "~> 0.9"
|
32
|
+
spec.add_development_dependency "www_app" , "> 2.0"
|
33
|
+
spec.add_development_dependency "bundler" , "~> 1.5"
|
34
|
+
spec.add_development_dependency "bacon" , "~> 1.0"
|
35
|
+
spec.add_development_dependency "Bacon_Colored" , "~> 0.1"
|
36
|
+
spec.add_development_dependency "thin" , "> 1.6"
|
37
|
+
spec.add_development_dependency "rack-contrib" , "> 0.1"
|
38
|
+
end
|
data/bin/akui
ADDED
data/lib/akui.rb
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
|
2
|
+
require 'cuba'
|
3
|
+
require 'escape_escape_escape'
|
4
|
+
|
5
|
+
class Akui
|
6
|
+
|
7
|
+
VERSION = `cat #{File.dirname __FILE__}/../VERSION`.strip
|
8
|
+
MOVED_TEMP = 302
|
9
|
+
|
10
|
+
class Middleware < Cuba
|
11
|
+
|
12
|
+
define {
|
13
|
+
on get do
|
14
|
+
on(root) {
|
15
|
+
res.write <<-EOF
|
16
|
+
<html>
|
17
|
+
<head>
|
18
|
+
<title>Akui v#{::Akui::VERSION}</title>
|
19
|
+
<style type="text/css">
|
20
|
+
body, pre {
|
21
|
+
background: #F2F2F2;
|
22
|
+
font-family: Ubuntu Mono, monospace;
|
23
|
+
}
|
24
|
+
a:link {
|
25
|
+
padding: 4px;
|
26
|
+
}
|
27
|
+
a:hover {
|
28
|
+
background: green;
|
29
|
+
color: #fff;
|
30
|
+
}
|
31
|
+
</style>
|
32
|
+
</head>
|
33
|
+
<body>
|
34
|
+
<a href="#{File.join req.env['REQUEST_PATH'], '/run'}">Run all</a>
|
35
|
+
<pre>#{::Akui.print}</pre>
|
36
|
+
</body>
|
37
|
+
</html>
|
38
|
+
EOF
|
39
|
+
}
|
40
|
+
|
41
|
+
on('results') {
|
42
|
+
Akui.stop
|
43
|
+
res.write <<-EOF
|
44
|
+
<html>
|
45
|
+
<head>
|
46
|
+
<title>Akui Results</title>
|
47
|
+
<style type="text/css">
|
48
|
+
body, pre {
|
49
|
+
background: #F2F2F2;
|
50
|
+
font-family: Ubuntu Mono, monospace;
|
51
|
+
}
|
52
|
+
a:link {
|
53
|
+
padding: 4px;
|
54
|
+
}
|
55
|
+
a:hover {
|
56
|
+
background: green;
|
57
|
+
color: #fff;
|
58
|
+
}
|
59
|
+
</style>
|
60
|
+
</head>
|
61
|
+
<body>
|
62
|
+
<p>All tests appear to have passed:</p>
|
63
|
+
<a href="#{File.expand_path(File.join req.env['REQUEST_PATH'], '../run')}">Run all</a>
|
64
|
+
<pre>#{::Akui.print}</pre>
|
65
|
+
</body>
|
66
|
+
</html>
|
67
|
+
EOF
|
68
|
+
}
|
69
|
+
|
70
|
+
on('inspect') {
|
71
|
+
res['Content-Type'] = 'application/json'
|
72
|
+
res.write Escape_Escape_Escape.json_encode({tests: ::Akui.tests})
|
73
|
+
}
|
74
|
+
|
75
|
+
on('run') {
|
76
|
+
Akui.reset
|
77
|
+
Akui.shift
|
78
|
+
res.redirect Akui.current[:parent][:path].to_s, ::Akui::MOVED_TEMP
|
79
|
+
}
|
80
|
+
end # === on get
|
81
|
+
|
82
|
+
|
83
|
+
on post do
|
84
|
+
on('result', param('result')) { |result|
|
85
|
+
past[:result] = result
|
86
|
+
res['Content-Type'] = 'application/json'
|
87
|
+
res.write Escape_Escape_Escape.json_encode({:result=>result})
|
88
|
+
}
|
89
|
+
|
90
|
+
on('run') {
|
91
|
+
pathname = URI.parse(req.env['HTTP_REFERER']).path
|
92
|
+
res['Content-Type'] = 'application/json'
|
93
|
+
|
94
|
+
case
|
95
|
+
when Akui.running? && !Akui.done?
|
96
|
+
test = Akui.shift
|
97
|
+
if pathname != test[:parent][:path].to_s
|
98
|
+
res.write Escape_Escape_Escape.json_encode({:test=>nil, :error=>"Wrong path name: expected: #{test[:parent][:path]} actual: #{pathname}"})
|
99
|
+
else
|
100
|
+
res.write Escape_Escape_Escape.json_encode({:test=>test})
|
101
|
+
end
|
102
|
+
|
103
|
+
when Akui.running? && Akui.done?
|
104
|
+
res.write Escape_Escape_Escape.json_encode({:test=>nil, :redirect=>File.expand_path(File.join(req.env['REQUEST_PATH'], '../results'))})
|
105
|
+
|
106
|
+
else
|
107
|
+
Akui.reset
|
108
|
+
Akui.shift
|
109
|
+
|
110
|
+
while (test = Akui.shift) && test[:parent][:path] != pathname
|
111
|
+
end
|
112
|
+
|
113
|
+
if test
|
114
|
+
res.write Escape_Escape_Escape.json_encode({:test=>test})
|
115
|
+
else
|
116
|
+
res.write Escape_Escape_Escape.json_encode({:test=>nil, :error=>'No test found.'})
|
117
|
+
end
|
118
|
+
end
|
119
|
+
}
|
120
|
+
end # === on pot
|
121
|
+
}
|
122
|
+
|
123
|
+
end # === class Middleware
|
124
|
+
|
125
|
+
class << self
|
126
|
+
|
127
|
+
def stop
|
128
|
+
@current_tests = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def reset
|
132
|
+
@current_tests = tests.map { |d|
|
133
|
+
d[:its].map { |i|
|
134
|
+
i = i.dup
|
135
|
+
i[:parent] = d
|
136
|
+
i
|
137
|
+
}
|
138
|
+
}.flatten
|
139
|
+
@current_tests.unshift false
|
140
|
+
@results = []
|
141
|
+
@past = []
|
142
|
+
end
|
143
|
+
|
144
|
+
def shift
|
145
|
+
t = @current_tests.shift
|
146
|
+
if @current_tests.empty?
|
147
|
+
end
|
148
|
+
@past.push t
|
149
|
+
t
|
150
|
+
end
|
151
|
+
|
152
|
+
def past
|
153
|
+
past.last
|
154
|
+
end
|
155
|
+
|
156
|
+
def current
|
157
|
+
@current_tests.first
|
158
|
+
end
|
159
|
+
|
160
|
+
def done?
|
161
|
+
running? && @current_tests.empty?
|
162
|
+
end
|
163
|
+
|
164
|
+
def running?
|
165
|
+
return false if !@current_tests
|
166
|
+
true
|
167
|
+
end
|
168
|
+
|
169
|
+
def print *args
|
170
|
+
type, o = args
|
171
|
+
case type
|
172
|
+
|
173
|
+
when nil, :all
|
174
|
+
tests.map { |desc|
|
175
|
+
print :desc, desc
|
176
|
+
}.join "\n".freeze
|
177
|
+
|
178
|
+
when :describe, :desc
|
179
|
+
%^DESC <a href="#{Escape_Escape_Escape.relative_href o[:path].to_s}">#{Escape_Escape_Escape.html o[:path].to_s}</a> #{o[:name] && o[:name].inspect}\n^ +
|
180
|
+
%^#{o[:its].map { |it| print :it, it }.join "\n"}^
|
181
|
+
|
182
|
+
when :it
|
183
|
+
%^ it #{o[:name].inspect}\n#{o[:script]}^
|
184
|
+
|
185
|
+
else
|
186
|
+
fail ArgumentError, "Unknown args: #{args.inspect}"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def define
|
191
|
+
instance_eval(&Proc.new)
|
192
|
+
end
|
193
|
+
|
194
|
+
def tests
|
195
|
+
@tests ||= []
|
196
|
+
end
|
197
|
+
|
198
|
+
def describe path, name = nil
|
199
|
+
if @current
|
200
|
+
fail <<-EOF.strip
|
201
|
+
NOTE:
|
202
|
+
Do not use DESCRIBE in nested fashion.
|
203
|
+
You can try, but it was not designed
|
204
|
+
to work like this, in order to make
|
205
|
+
my life easier w/ a simple implementation.
|
206
|
+
|
207
|
+
Use it like this:
|
208
|
+
describe {
|
209
|
+
}
|
210
|
+
|
211
|
+
describe {
|
212
|
+
}
|
213
|
+
|
214
|
+
describe {
|
215
|
+
}
|
216
|
+
EOF
|
217
|
+
end
|
218
|
+
|
219
|
+
tests.<<(
|
220
|
+
@current = {
|
221
|
+
:path => path,
|
222
|
+
:name => name,
|
223
|
+
:its => []
|
224
|
+
}
|
225
|
+
)
|
226
|
+
yield
|
227
|
+
@current = nil
|
228
|
+
end
|
229
|
+
|
230
|
+
def it name, script_str
|
231
|
+
if @current
|
232
|
+
@current[:its] << {
|
233
|
+
:name => name,
|
234
|
+
:script => script_str
|
235
|
+
}
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
end # === class << self
|
240
|
+
|
241
|
+
end # === class Akui ===
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Tests for...</title>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<link rel="stylesheet" type="text/css" href="./akui_tests/style.css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<div id="stage"></div>
|
11
|
+
|
12
|
+
<div id="results" onclick="window.location.reload();"></div>
|
13
|
+
|
14
|
+
<script type="text/_csrf" id="_csrf">{{_csrf}}</script>
|
15
|
+
<script type="text/javascript" src="./akui_tests/jquery.js"></script>
|
16
|
+
<script type="text/javascript" src="./akui_tests/underscore.js"></script>
|
17
|
+
<script type="text/javascript" src="./akui_tests/promise.js"></script>
|
18
|
+
<script type="text/javascript" src="./akui_tests/fermata.js"></script>
|
19
|
+
<script type="text/javascript" src="./akui_tests/akui.js"></script>
|
20
|
+
|
21
|
+
<!-- ...................... -->
|
22
|
+
<!-- ...................... -->
|
23
|
+
|
24
|
+
</body>
|
25
|
+
</html>
|
26
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* jshint undef: true, unused: true */
|
3
|
+
/* global _, fermata */
|
4
|
+
/* exported _, fermata */
|
5
|
+
|
6
|
+
// === SCOPE
|
7
|
+
(function () {
|
8
|
+
var results = [];
|
9
|
+
|
10
|
+
var should = {
|
11
|
+
equal: function (one, two) {
|
12
|
+
if (_.isEqual(one,two)) {
|
13
|
+
results.push(true);
|
14
|
+
} else {
|
15
|
+
throw new Error('Failed: !_.isEqual: ' + one + ' !== ' + two);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}; // var should
|
19
|
+
|
20
|
+
var log = function () {
|
21
|
+
console['log'].apply(console, arguments);
|
22
|
+
}; // === func
|
23
|
+
|
24
|
+
fermata.json('/akui/run').post(function (err, data, headers) {
|
25
|
+
log(headers);
|
26
|
+
log(data);
|
27
|
+
if (err) {
|
28
|
+
log(err);
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
|
32
|
+
if (!data.test && data.redirect) {
|
33
|
+
window.location.href = data.redirect;
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
|
37
|
+
if (data.error)
|
38
|
+
throw new Error(data.error);
|
39
|
+
|
40
|
+
log(data.test.script);
|
41
|
+
var test_result = (new Function('should', data.test.script))(should);
|
42
|
+
|
43
|
+
if (_.isEmpty(results))
|
44
|
+
throw new Error("Empty specifications: \n" + data.test.script);
|
45
|
+
|
46
|
+
if (_.isFunction(test_result))
|
47
|
+
test_result();
|
48
|
+
else {
|
49
|
+
log(results);
|
50
|
+
log('Done running tests.');
|
51
|
+
}
|
52
|
+
});
|
53
|
+
})();
|
Binary file
|
@@ -0,0 +1,6 @@
|
|
1
|
+
body { background: #F0F0F0; padding-bottom: 50px; }
|
2
|
+
#results div { padding: 10px ; margin-right: 5px; margin-bottom: 5px; }
|
3
|
+
#results span { font-size: 90%; font-family: monospace; font-weight: bold; }
|
4
|
+
div.passed { background: #CFDB00; float: left; }
|
5
|
+
div.failed { background: #DB0013; float: left; }
|
6
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
SCRIPTS = <<-EOF
|
3
|
+
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
|
4
|
+
<script src="/bower_components/lodash/lodash.min.js"></script>
|
5
|
+
<script src="/bower_components/fermata/fermata.js"></script>
|
6
|
+
<script src="/akui/akui.js"></script>
|
7
|
+
EOF
|
8
|
+
|
9
|
+
Cuba.define do
|
10
|
+
|
11
|
+
on 'akui' do
|
12
|
+
run Akui::Middleware
|
13
|
+
end
|
14
|
+
|
15
|
+
on 'finished' do
|
16
|
+
`touch Public/finished.txt`
|
17
|
+
res.redirect '/akui/results', Akui::MOVED_TEMP
|
18
|
+
end
|
19
|
+
|
20
|
+
on get do
|
21
|
+
on root do
|
22
|
+
res.write <<-EOF.strip
|
23
|
+
<html>
|
24
|
+
<head><title>Root</title></head>
|
25
|
+
<body>
|
26
|
+
<div>Root</div>
|
27
|
+
<a href="/1">one</a>
|
28
|
+
#{ Akui.running? ? SCRIPTS : '<!-- Akui is not running -->'}
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
EOF
|
32
|
+
end
|
33
|
+
|
34
|
+
vals = {1=>:one, 2=>:two, 3=>:three, 4=>:root}
|
35
|
+
vals.each do |n, k|
|
36
|
+
on "#{n}" do
|
37
|
+
res.write <<-EOF.strip
|
38
|
+
<html>
|
39
|
+
<head><title>#{k}</title></head>
|
40
|
+
<body>
|
41
|
+
<a href="/#{n + 1 == 4 ? '' : n + 1}">#{vals[n+1]}</a>
|
42
|
+
#{SCRIPTS}
|
43
|
+
</body>
|
44
|
+
</html>
|
45
|
+
EOF
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end # === Cuba.define
|
51
|
+
|
52
|
+
Akui.define {
|
53
|
+
|
54
|
+
describe :/, 'Root' do
|
55
|
+
|
56
|
+
it 'has link to: /1', <<-EOF
|
57
|
+
var link = $('a[href="/1"]');
|
58
|
+
should.equal( link.text(), 'one' );
|
59
|
+
link[0].click();
|
60
|
+
EOF
|
61
|
+
|
62
|
+
end # === describe
|
63
|
+
|
64
|
+
describe '/1' do
|
65
|
+
it 'has link to: /2', <<-EOF
|
66
|
+
var link = $('a[href="/2"]');
|
67
|
+
should.equal( link.text(), 'two' );
|
68
|
+
link[0].click();
|
69
|
+
EOF
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '/2' do
|
73
|
+
it 'has link to: /3', <<-EOF
|
74
|
+
var link = $('a[href="/3"]');
|
75
|
+
should.equal( link.text(), 'three' );
|
76
|
+
link[0].click();
|
77
|
+
EOF
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '/3' do
|
81
|
+
it 'has link to: /', <<-EOF
|
82
|
+
var link = $('a[href="/"]');
|
83
|
+
should.equal( link.text(), 'root' );
|
84
|
+
window.location.href = "/finished";
|
85
|
+
EOF
|
86
|
+
end
|
87
|
+
|
88
|
+
} # === Akui.define
|
data/specs/config.ru
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'cuba'
|
3
|
+
require 'rack/contrib'
|
4
|
+
require 'akui'
|
5
|
+
|
6
|
+
Cuba.use Rack::CommonLogger
|
7
|
+
|
8
|
+
# === From:
|
9
|
+
# https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/try_static.rb
|
10
|
+
class Custom_Try_Static
|
11
|
+
|
12
|
+
def initialize(app, options)
|
13
|
+
@app = app
|
14
|
+
@try = ['', *options[:try]]
|
15
|
+
@static = ::Rack::Static.new(
|
16
|
+
lambda { |_| [404, {}, []] },
|
17
|
+
options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
return @app.call(env) unless %w[GET HEAD].include?(env['REQUEST_METHOD'])
|
22
|
+
orig_path = env['PATH_INFO']
|
23
|
+
found = nil
|
24
|
+
@try.each do |path|
|
25
|
+
resp = @static.call(env.merge!({'PATH_INFO' => orig_path + path}))
|
26
|
+
break if !(403..405).include?(resp[0]) && found = resp
|
27
|
+
end
|
28
|
+
found or @app.call(env.merge!('PATH_INFO' => orig_path))
|
29
|
+
end
|
30
|
+
|
31
|
+
end # === class Custom_Try_Static
|
32
|
+
|
33
|
+
Cuba.use Custom_Try_Static, :root => "Public", :urls=>%w[/]
|
34
|
+
|
35
|
+
require "./specs/#{ENV['SPEC_FILE']}/spec"
|
36
|
+
run Cuba
|
data/specs/helpers.rb
ADDED
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: akui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- da99
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cuba
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: escape_escape_escape
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: www_app
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bacon
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: Bacon_Colored
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thin
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.6'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.6'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rack-contrib
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.1'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.1'
|
139
|
+
description: "\n Automate testing code on the browser by using Rack\n middleware
|
140
|
+
to include JS testing code files\n into your rendered HTML.\n "
|
141
|
+
email:
|
142
|
+
- i-hate-spam-1234567@mailinator.com
|
143
|
+
executables:
|
144
|
+
- akui
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files: []
|
147
|
+
files:
|
148
|
+
- ".bowerrc"
|
149
|
+
- ".gitignore"
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE
|
152
|
+
- README.md
|
153
|
+
- VERSION
|
154
|
+
- akui
|
155
|
+
- akui.gemspec
|
156
|
+
- bin/akui
|
157
|
+
- lib/akui.rb
|
158
|
+
- lib/browser/_index.html
|
159
|
+
- lib/browser/akui/akui.js
|
160
|
+
- lib/browser/favicon.ico
|
161
|
+
- lib/browser/style.css
|
162
|
+
- lib/browser/window.onerror.js
|
163
|
+
- specs/0000-it-runs/spec.rb
|
164
|
+
- specs/config.ru
|
165
|
+
- specs/helpers.rb
|
166
|
+
homepage: https://github.com/da99/akui
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: 2.2.0
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.4.5
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: My way of testing browser/client-side code.
|
190
|
+
test_files: []
|