Sha256: 48215cfd436d1cca37ff92fe671802c75c55aecdc60e05667e398d709b18c548

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

module Jasmine
  class RunAdapter
    alias _run run
    # overridden method so that we can use a custom html file
    #noinspection RubyUnusedLocalVariable
    def run(focused_suite = nil)
      # regenerate volatile files
      Rake::Task['compile'].execute if $JAX_DEVELOPMENT             # rebuild jax itself if we're in gem development
      Rake::Task['jax:generate_files'].execute if !$JAX_RAKE        # rebuild the project resources, routes, etc
      
      custom_file = Jax.root && Jax.root.join("spec/javascripts/support/spec_layout.html.erb")
      return _run(focused_suite) if !custom_file || !File.file?(custom_file)
      
      jasmine_files = @jasmine_files
      css_files = @jasmine_stylesheets + (@config.css_files || [])
      js_files = @config.js_files(focused_suite)
      body = ERB.new(File.read(custom_file)).result(binding)
      [
        200,
        { 'Content-Type' => 'text/html' },
        [body]
      ]
    end
  end
  
  # overridden so that we can map source files separately from /public
  def self.app(config)
    Rack::Builder.app do
      use Rack::Head
      
      map("/run.html")  { run Jasmine::Redirect.new('/') }
      map("/__suite__") { run Jasmine::FocusedSuite.new(config) }
      
      map("/__JASMINE_ROOT__") { run Rack::File.new(Jasmine.root) }
      map(config.spec_path) { run Rack::File.new(config.project_root) }
      map(config.root_path) { run Rack::File.new(config.project_root) }
      
      map '/' do
        run Rack::Cascade.new([
          Rack::URLMap.new(
            '/' => Rack::File.new(config.root_dir),
            '/__src__' => Rack::File.new(config.src_dir)
          ),
        
          Jasmine::RunAdapter.new(config)
        ])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jax-1.1.1 lib/jax/monkeypatch/jasmine/server.rb
jax-1.1.0 lib/jax/monkeypatch/jasmine/server.rb
jax-1.1.0.rc1 lib/jax/monkeypatch/jasmine/server.rb