Class: MSpec::Opal::Runner
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#port ⇒ Object
Returns the value of attribute port.
-
#server_pid ⇒ Object
readonly
Returns the value of attribute server_pid.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Runner
constructor
A new instance of Runner.
- #passed? ⇒ Boolean
- #run ⇒ Object
- #start_phantomjs ⇒ Object
- #start_server ⇒ Object
- #stop_server ⇒ Object
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
64 65 66 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 64 def app @app end |
#port ⇒ Object
Returns the value of attribute port
65 66 67 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 65 def port @port end |
#server_pid ⇒ Object (readonly)
Returns the value of attribute server_pid
64 65 66 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 64 def server_pid @server_pid end |
Instance Method Details
#passed? ⇒ Boolean
67 68 69 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 67 def passed? @passed end |
#run ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 71 def run start_server start_phantomjs exit 1 unless passed? rescue => e puts e. ensure stop_server if server_pid end |
#start_phantomjs ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 87 def start_phantomjs require 'shellwords' runner = File.('../sprockets.js', __FILE__).shellescape url = "http://localhost:#{port}/".shellescape command = %Q{phantomjs #{runner} #{url}} @passed = system command end |
#start_server ⇒ Object
96 97 98 99 100 101 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 96 def start_server @server_pid = fork do Rack::Server.start(:app => app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log.new("/dev/null")) end end |
#stop_server ⇒ Object
82 83 84 85 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 82 def stop_server Process.kill(:SIGINT, server_pid) Process.wait end |