Class: FrontEndTasks::Spec
- Inherits:
-
Object
- Object
- FrontEndTasks::Spec
- Defined in:
- lib/front_end_tasks/spec.rb
Constant Summary collapse
- ES5_SHIM =
File.(File.join(__dir__, '../..', 'vendor/es5-shim/es5-shim.js'))
- WORKER_SHIM =
File.(File.join(__dir__, '../..', 'vendor/worker-shim/worker-shim.js'))
Class Method Summary collapse
-
.run(opts) ⇒ Object
mostly taken from github.com/pivotal/jasmine-gem/blob/master/lib/jasmine/tasks/jasmine.rake.
Class Method Details
.run(opts) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/front_end_tasks/spec.rb', line 9 def self.run(opts) config = Jasmine.config config.src_dir = File.('./') config.spec_dir = File.('./') config.ci_port = opts[:port] if opts[:source_files] source_files = opts[:source_files] elsif opts[:worker_file] source_files = [] source_files << '__worker-shim.js__' config.add_rack_path('/__worker-shim.js__', lambda { Rack::File.new(WORKER_SHIM) }) js_doc = Documents::JsDocument.new(nil, File.read(opts[:worker_file])) source_files += js_doc.included_scripts.map { |s| File.join(opts[:public_root], s) } source_files << opts[:worker_file] end helper_files = opts[:helper_files] || [] # hack the es5-shim to load before src files config.add_rack_path('/__es5-shim.js__', lambda { Rack::File.new(ES5_SHIM) }) config.src_files = lambda { ['__es5-shim.js__'] + source_files } config.spec_files = lambda { helper_files + opts[:spec_files] } server = Jasmine::Server.new(config.port(:ci), Jasmine::Application.app(config)) t = Thread.new do begin server.start rescue ChildProcess::TimeoutError end # # ignore bad exits end t.abort_on_exception = true Jasmine::wait_for_listener(config.port(:ci), 'jasmine server') puts 'jasmine server started.' formatters = config.formatters.map { |formatter_class| formatter_class.new } exit_code_formatter = Jasmine::Formatters::ExitCode.new formatters << exit_code_formatter url = "#{config.host}:#{config.port(:ci)}/" runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url) runner.run exit(1) unless exit_code_formatter.succeeded? end |