Class: Jasmine::RunAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/jasmine-ruby/jasmine_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec_files_or_proc, options = {}) ⇒ RunAdapter

Returns a new instance of RunAdapter.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jasmine-ruby/jasmine_runner.rb', line 65

def initialize(spec_files_or_proc, options = {})
  @spec_files_or_proc = Jasmine.files(spec_files_or_proc) || []
  @jasmine_files = Jasmine.files(options[: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",
  ]
  @stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"] + (Jasmine.files(options[:stylesheets]) || [])
  @spec_helpers = Jasmine.files(options[:spec_helpers]) || []
end

Instance Method Details

#call(env) ⇒ Object



77
78
79
# File 'lib/jasmine-ruby/jasmine_runner.rb', line 77

def call(env)
  run
end

#runObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/jasmine-ruby/jasmine_runner.rb', line 81

def run
  stylesheets = @stylesheets
  spec_helpers = @spec_helpers
  spec_files = @spec_files_or_proc

  jasmine_files = @jasmine_files
  jasmine_files = jasmine_files.call if jasmine_files.respond_to?(:call)

  css_files = @stylesheets


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