Sha256: 8ba4ed0f75f4b30f58ed3bdf36da2b2d2d2d44a2320bff932c2aabdf5b24c632

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require 'jasmine-core'

module Lanes
    module API


        class TestSpecs

            cattr_accessor :current

            attr_accessor :extension
            def initialize(ext)
                @extension = ext
            end

            def css_files
                urlpath Jasmine::Core.css_files
            end

            def js_files
                urlpath(Jasmine::Core.js_files)   +
                urlpath(Jasmine::Core.boot_files) +
                ['/assets/lanes/testing'] +
                urlpath(spec_files(extension.identifier))
            end

          private

            def spec_files(path)
                dir = extension.root_path.join("spec")
                regex = /^#{dir}\//
                Dir.glob( dir.join(path,"**/*.{coffee,cjsx,js}") ).map do |file|
                    file.sub(regex,'').sub(/(coffee|cjsx)$/,'js')
                end
            end

            def urlpath(files)
                files.map{ |file| "/spec/"+file }
            end
        end

        ext = Extensions.controlling
        TestSpecs.current = TestSpecs.new(ext)
        Root.sprockets.append_path(ext.root_path.join("spec"))
        Root.sprockets.append_path(Jasmine::Core.path)

        routes.draw do

            get '/spec' do
                content_type 'text/html'
                erb :specs, locals: { specs: TestSpecs.current }
            end

            get "/spec/*" do |path|
                env_sprockets = request.env.dup
                env_sprockets['PATH_INFO'] = path
                settings.sprockets.call env_sprockets
            end

        end
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lanes-0.7.0 lib/lanes/api/test_specs.rb
lanes-0.6.1 lib/lanes/api/test_specs.rb
lanes-0.6.0 lib/lanes/api/test_specs.rb
lanes-0.5.6 lib/lanes/api/test_specs.rb
lanes-0.5.5 lib/lanes/api/test_specs.rb
lanes-0.5.0 lib/lanes/api/test_specs.rb
lanes-0.4.0 lib/lanes/api/test_specs.rb
lanes-0.3.0 lib/lanes/api/test_specs.rb
lanes-0.1.9.5 lib/lanes/api/test_specs.rb