Sha256: 1de608b137da9a02ea0392c804b0a76ad33e75162a2a8f6d500f325fb8f04bda

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Evergreen
  def self.application(suite)
    Rack::Builder.new do
      instance_eval(&Evergreen.extensions) if Evergreen.extensions

      map "/jasmine" do
        use Rack::Static, :urls => ["/"], :root => File.expand_path('../jasmine/lib', File.dirname(__FILE__))
        run lambda { |env| [404, {}, "No such file"]}
      end

      map "/resources" do
        use Rack::Static, :urls => ["/"], :root => File.expand_path('resources', File.dirname(__FILE__))
        run lambda { |env| [404, {}, "No such file"]}
      end

      map "/" do
        app = Class.new(Sinatra::Base).tap do |app|
          app.reset!
          app.class_eval do
            set :static, true
            set :root, File.expand_path('.', File.dirname(__FILE__))
            set :public, File.expand_path(File.join(suite.root, Evergreen.public_dir), File.dirname(__FILE__))

            helpers do
              def url(path)
                request.env['SCRIPT_NAME'].to_s + path.to_s
              end
            end

            get '/' do
              @suite = suite
              erb :list
            end

            get '/run/*' do |name|
              @suite = suite
              @spec = suite.get_spec(name)
              @js_spec_helper = suite.get_spec('spec_helper.js')
              @coffee_spec_helper = suite.get_spec('spec_helper.coffee')
              erb :spec
            end
          end
        end
        run app
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evergreen-0.4.1 lib/evergreen/application.rb