Class: Opal::Spec::RakeTask
- Inherits:
-
Object
- Object
- Opal::Spec::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/opal/spec/rake_task.rb
Constant Summary collapse
- RUNNER =
File.('../../../../vendor/spec_runner.js', __FILE__)
- PORT =
9999
- URL =
"http://localhost:9999/"
Instance Method Summary collapse
-
#initialize(name = 'opal:test', &block) ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(name = 'opal:test', &block) ⇒ RakeTask
Returns a new instance of RakeTask.
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 |
# File 'lib/opal/spec/rake_task.rb', line 13 def initialize(name = 'opal:test', &block) desc "Run opal specs in phantomjs" task name do require 'rack' require 'webrick' server = fork do app = Opal::Server.new { |s| s.main = 'opal/spec/sprockets_runner' s.append_path 'spec' s.debug = false block.call s if block } Rack::Server.start(:app => app, :Port => PORT, :AccessLog => [], :Logger => WEBrick::Log.new("/dev/null")) end system "phantomjs #{RUNNER} \"#{URL}\"" success = $?.success? Process.kill(:SIGINT, server) Process.wait exit 1 unless success end end |