Class: MSpec::Opal::Runner
Defined Under Namespace
Classes: PhantomJS
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#port ⇒ Object
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
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
#initialize(&block) ⇒ Runner
Returns a new instance of Runner
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 40 def initialize &block @app = Rack::Builder.new do ::Opal::Processor.arity_check_enabled = true ::Opal::Processor.dynamic_require_severity = :error use Rack::ShowExceptions use Rack::ShowStatus use MSpec::Opal::Index run MSpec::Opal::Environment.new end @port = 9999 end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
54 55 56 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 54 def app @app end |
#port ⇒ Object
Returns the value of attribute port
55 56 57 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 55 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server
54 55 56 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 54 def server @server end |
Instance Method Details
#passed? ⇒ Boolean
57 58 59 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 57 def passed? @passed end |
#run ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 61 def run start_server start_phantomjs exit 1 unless passed? rescue => e puts e. ensure stop_server if server end |
#start_phantomjs ⇒ Object
91 92 93 94 95 96 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 91 def start_phantomjs runner = File.('../sprockets.js', __FILE__).shellescape url = "http://localhost:#{port}/".shellescape command = PhantomJS.new(runner, url) @passed = command.run end |
#start_server ⇒ Object
98 99 100 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 98 def start_server @server = Thread.new { Rack::Server.start(:app => app, :Port => port) } end |
#stop_server ⇒ Object
72 73 74 |
# File 'opal/lib/mspec/opal/rake_task.rb', line 72 def stop_server server.kill end |