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
|
# File 'app/webr.rb', line 22
def jasmine(file_name)
raise "No such file: #{file_name}" unless File.exist?(file_name)
files = []
if File.directory?(file_name)
root = File.expand_path(file_name)
files += Dir["#{root}/*_spec.js"]
else
files << File.expand_path(file_name)
root = File.dirname(File.expand_path(file_name))
end
format = params["format"]
begin
browser = Webr::Jasmine::Browser.new(format)
browser.root = root
files.each do |file|
browser.scripts << file
end
browser.start
rescue Exception => e
if format == 'html'
puts "<pre>"
puts h(e.message)
puts h(e.backtrace.join("\n"))
puts "</pre>"
else
raise
end
end
end
|