Class: ELA::Jasmine

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

Constant Summary collapse

ELA_SRC_FILE_SPECS =
[
  'vendor/webfontloader-*.js',
  'vendor/jquery-*.js',
  'vendor/hammer-*.js',
  'vendor/underscore-*.js',
  'vendor/backbone-*.js',
  'vendor/backbone.poised/underscore_ext.js',
  'vendor/backbone.poised/patches.js',
  'vendor/backbone.poised/view.js',
  'vendor/backbone.poised/**/*.js',
  'vendor/poised/**/*.js',
  'vendor/markup_text.js',
  'vendor/request_animation_frame.js',
  'vendor/js-yaml-*.js',
  'vendor/gaussianElimination.js',
  'lib/bootstrap_data.js',
  'lib/application.js',
  'lib/models/base_app_model.js',
  'lib/models/**/*.js',
  'lib/collections/**/*.js',
  'lib/views/canvas.js',
  'lib/views/base_graph.js',
  'lib/router.js'
]
APP_SRC_FILE_SPECS =
[
  '*/models/**/*.js',
  '*/collections/**/*.js'
]
ELA_SPEC_HELPERS_PREFIX =
'/__ela_spec_helpers__'
ELA_SPEC_HELPERS_PATH =
File.expand_path('../../dist/spec_helpers', __dir__)
ELA_JS_PREFIX =
'/__ela_src__'
ELA_JS_PATH =
File.expand_path('../../dist/app_js', __dir__)

Class Method Summary collapse

Class Method Details

.expand_specs(specs, path, prefix = '') ⇒ Object



79
80
81
82
83
84
85
# File 'lib/ela/jasmine.rb', line 79

def self.expand_specs(specs, path, prefix = '')
  specs.map do |spec|
    Dir[File.join(path, spec)].map do |file|
      file.gsub(path, prefix)
    end.sort
  end
end

.runObject



62
63
64
65
# File 'lib/ela/jasmine.rb', line 62

def self.run
  configure
  ::Jasmine::CiRunner.new(::Jasmine.config).run
end

.spec_filesObject



75
76
77
# File 'lib/ela/jasmine.rb', line 75

def self.spec_files
  Dir.glob(File.join(Dir.pwd, 'spec/javascripts/**/*[sS]pec.js'))
end

.src_filesObject



67
68
69
70
71
72
73
# File 'lib/ela/jasmine.rb', line 67

def self.src_files
  [
    expand_specs(ELA_SRC_FILE_SPECS, ELA_JS_PATH, ELA_JS_PREFIX),
    expand_specs(APP_SRC_FILE_SPECS, ::Jasmine.config.src_dir),
    expand_specs(['**/*.js'], ELA_SPEC_HELPERS_PATH, ELA_SPEC_HELPERS_PREFIX)
  ].flatten
end

.start_serverObject



53
54
55
56
57
58
59
60
# File 'lib/ela/jasmine.rb', line 53

def self.start_server
  configure
  ::Jasmine::Server.new(
    ::Jasmine.config.port(:server),
    ::Jasmine::Application.app(::Jasmine.config),
    ::Jasmine.config.rack_options
  ).start
end