Class: Jasmine::RunAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/jasmine/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RunAdapter

Returns a new instance of RunAdapter.



29
30
31
32
33
34
35
36
37
# File 'lib/jasmine/server.rb', line 29

def initialize(config)
  @config = config
  @jasmine_files = [
    "/__JASMINE_ROOT__/lib/jasmine.js",
    "/__JASMINE_ROOT__/lib/jasmine-html.js",
    "/__JASMINE_ROOT__/lib/json2.js",
  ]
  @jasmine_stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"]
end

Instance Method Details

#call(env) ⇒ Object



39
40
41
42
# File 'lib/jasmine/server.rb', line 39

def call(env)
  return not_found if env["PATH_INFO"] != "/"
  run
end

#not_foundObject



44
45
46
47
48
49
50
# File 'lib/jasmine/server.rb', line 44

def not_found
  body = "File not found: #{@path_info}\n"
  [404, {"Content-Type" => "text/plain",
         "Content-Length" => body.size.to_s,
         "X-Cascade" => "pass"},
   [body]]
end

#run(focused_suite = nil) ⇒ Object

noinspection RubyUnusedLocalVariable



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/jasmine/server.rb', line 53

def run(focused_suite = nil)
  jasmine_files = @jasmine_files
  css_files = @jasmine_stylesheets + (@config.css_files || [])
  js_files = @config.js_files(focused_suite)
  body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding)
  [
    200,
    { 'Content-Type' => 'text/html' },
    body
  ]
end