forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_controller.rb
More file actions
66 lines (54 loc) · 1.37 KB
/
test_controller.rb
File metadata and controls
66 lines (54 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Stringer < Sinatra::Base
def self.test_path(*chunks)
File.expand_path(File.join("..", *chunks), __FILE__)
end
get "/test" do
erb File.read(self.class.test_path("support", "views", "index.erb")), layout: false, locals: {
js_files: js_files,
js_templates: js_templates
}
end
get "/spec/*" do
send_file self.class.test_path("spec", *params[:splat])
end
get "/vendor/*" do
send_file self.class.test_path("support", "vendor", *params[:splat])
end
private
def vendor_js_files
%w(mocha.js sinon.js chai.js chai-changes.js chai-backbone.js sinon-chai.js).map do |name|
File.join "vendor", "js", name
end
end
def vendor_css_files
%w(mocha.css).map do |name|
File.join "vendor", "css", name
end
end
def js_helper_files
%w(spec_helper.js).map do |name|
File.join "spec", name
end
end
def js_lib_files
base = self.class.test_path("..", "..", "app", "public")
Dir[File.join(base, "js", "**", "*.js")].map do |lib_file|
lib_file.sub!(base, "")
end
end
def js_test_files
base = self.class.test_path
Dir[File.join(base, "**", "*_spec.js")].map do |spec_file|
spec_file.sub!(base, "")
end
end
def js_files
vendor_js_files + js_helper_files + js_test_files
end
def css_files
vendor_css_files
end
def js_templates
[:story]
end
end