Fix compatibility with the ruby contrib runner
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
require 'socket'
|
||||
require 'erb'
|
||||
require 'json'
|
||||
|
||||
module Jasmine
|
||||
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
||||
@@ -61,11 +62,26 @@ module Jasmine
|
||||
end
|
||||
end
|
||||
|
||||
class Redirect
|
||||
def initialize(url)
|
||||
@url = url
|
||||
end
|
||||
|
||||
def call(env)
|
||||
[
|
||||
302,
|
||||
{ 'Location' => @url },
|
||||
[]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
class SimpleServer
|
||||
def self.start(port, spec_files_or_proc, mappings)
|
||||
require 'thin'
|
||||
|
||||
config = {
|
||||
'/' => Jasmine::Redirect.new('/run.html'),
|
||||
'/run.html' => Jasmine::RunAdapter.new(spec_files_or_proc)
|
||||
}
|
||||
mappings.each do |from, to|
|
||||
@@ -116,7 +132,7 @@ module Jasmine
|
||||
def eval_js(script)
|
||||
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
|
||||
|
||||
result = @driver.get_eval("window.eval(#{escaped_script})")
|
||||
result = @driver.get_eval("eval(#{escaped_script}, window)")
|
||||
JSON.parse("[#{result}]")[0]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user