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.



3
4
5
6
7
8
9
10
11
12
# File 'lib/jasmine/server.rb', line 3

def initialize(config)
  @config = config
  @jasmine_files = [
    "/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
    "/__JASMINE_ROOT__/lib/TrivialReporter.js",
    "/__JASMINE_ROOT__/lib/json2.js",
    "/__JASMINE_ROOT__/lib/consolex.js",
  ]
  @jasmine_stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"]
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
# File 'lib/jasmine/server.rb', line 14

def call(env)
  run
end

#runObject

noinspection RubyUnusedLocalVariable



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jasmine/server.rb', line 19

def run
  jasmine_files = @jasmine_files
  css_files = @jasmine_stylesheets + (Jasmine.files(@config.stylesheets) || [])
  js_files = Jasmine.files(@config.js_files)

  body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding)
  [
    200,
    { 'Content-Type' => 'text/html' },
    body
  ]
end