Class: Jasmine::FocusedSuite

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FocusedSuite

Returns a new instance of FocusedSuite.



60
61
62
63
64
# File 'lib/jasmine/server.rb', line 60

def initialize(config)
  @config = config
#      @spec_files_or_proc = Jasmine.files(spec_files_or_proc) || []
#      @options = options
end

Instance Method Details

#call(env) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/jasmine/server.rb', line 66

def call(env)
  spec_files = Jasmine.files(@config.spec_files_or_proc)
  matching_specs = spec_files.select {|spec_file| spec_file =~ /#{Regexp.escape(env["PATH_INFO"])}/ }.compact
  if !matching_specs.empty?
    run_adapter = Jasmine::RunAdapter.new(matching_specs, @options)
    run_adapter.run
  else
    [
      200,
      { 'Content-Type' => 'application/javascript' },
      "document.write('<p>Couldn\\'t find any specs matching #{env["PATH_INFO"]}!</p>');"
    ]
  end
end