Class: RSpec::Jasmine::SpecRunner

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

Class Method Summary collapse

Class Method Details

.run(world, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rspec/jasmine/spec_runner.rb', line 8

def self.run(world, options = {})
  suites = options[:suites] || ENV['JASMINE_SUITES'].to_s.split(':')
  return if suites.empty?
  
  builders = suites.map do |suite|
    RSpec::Jasmine::SpecBuilder.new(world, options.merge(:suite => suite))
  end
  
  first_builder = builders.first
  
  Thread.new do
    Rack::Server.new({
      :app       => options[:app],
      :Port      => first_builder.port,
      :Host      => first_builder.host,
    }).start { |s| s.silent = true }
  end
  
  require 'rspec/core/runner'
  
  builders.each_with_index do |builder, id|
    RSpec.configuration.after(:suite) do
      builder.stop
    end
  
    puts if id > 0
    builder.start
    RSpec::Core::Runner.run([])
  end
  
  if Jasmine.failed
    exit(1)
  end
end