Sha256: 76329a68e07ba7cc502dffef6f8702edb33951ad82e02a0ff4274ec24c4496f6

Contents?: true

Size: 1.7 KB

Versions: 14

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.spec_dir) }
      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

14 entries across 14 versions & 1 rubygems

Version Path
jax-1.0.1 lib/jax/monkeypatch/jasmine/server.rb
jax-1.0.1.rc2 lib/jax/monkeypatch/jasmine/server.rb
jax-1.0.1.rc1 lib/jax/monkeypatch/jasmine/server.rb
jax-1.0.0 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.10 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.9 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.8 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.7 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.6 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.5 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.4 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.3 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.2 lib/jax/monkeypatch/jasmine/server.rb
jax-0.0.0.1 lib/jax/monkeypatch/jasmine/server.rb