37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/simple_javascript_testing.rb', line 37
def call_template_with_js(template, &block)
data = AnyClass.new
if block_given?
yield data
end
FileUtils.mkdir_p("test/html/#{File.dirname template}")
FileUtils.mkdir_p("test/javascript/#{File.dirname template}")
html = data.build_html(template)
html.gsub!("<head>", "<head><script src='#{File.expand_path('node_modules')}/simple_javascript_testing/lib/stub_ajax.js'></script>")
html.gsub!("<script src='#{AnyClass.prefix}", "<script src='#{File.expand_path('public')}")
File.write("test/html/#{template}.html", html)
thing = "#{File.expand_path('html', 'test')}/#{template}"
thing2 = "#{File.expand_path('javascript', 'test')}/#{template}"
system "phantomjs #{thing2}.js #{thing}.html"
end
|