Class: Jasmine::Runners::PhantomJs
- Inherits:
-
Object
- Object
- Jasmine::Runners::PhantomJs
- Defined in:
- lib/jasmine/runners/phantom_js.rb
Instance Method Summary collapse
- #boot_js ⇒ Object
- #cli_options_string ⇒ Object
-
#initialize(formatter, jasmine_server_url, prevent_phantom_js_auto_install, show_console_log, phantom_config_script, show_full_stack_trace, cli_options = nil) ⇒ PhantomJs
constructor
A new instance of PhantomJs.
- #phantom_js_path ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(formatter, jasmine_server_url, prevent_phantom_js_auto_install, show_console_log, phantom_config_script, show_full_stack_trace, cli_options = nil) ⇒ PhantomJs
Returns a new instance of PhantomJs.
7 8 9 10 11 12 13 14 15 |
# File 'lib/jasmine/runners/phantom_js.rb', line 7 def initialize(formatter, jasmine_server_url, prevent_phantom_js_auto_install, show_console_log, phantom_config_script, show_full_stack_trace, = nil) @formatter = formatter @jasmine_server_url = jasmine_server_url @prevent_phantom_js_auto_install = prevent_phantom_js_auto_install @show_console_log = show_console_log @phantom_config_script = phantom_config_script @show_full_stack_trace = show_full_stack_trace @cli_options = || {} end |
Instance Method Details
#boot_js ⇒ Object
60 61 62 |
# File 'lib/jasmine/runners/phantom_js.rb', line 60 def boot_js File.('phantom_boot.js', File.dirname(__FILE__)) end |
#cli_options_string ⇒ Object
64 65 66 67 68 |
# File 'lib/jasmine/runners/phantom_js.rb', line 64 def @cli_options. map {|(k, v)| "--#{k}=#{v}"}. join(' ') end |
#phantom_js_path ⇒ Object
56 57 58 |
# File 'lib/jasmine/runners/phantom_js.rb', line 56 def phantom_js_path prevent_phantom_js_auto_install ? 'phantomjs' : Phantomjs.path end |
#run ⇒ Object
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 |
# File 'lib/jasmine/runners/phantom_js.rb', line 17 def run phantom_script = File.join(File.dirname(__FILE__), 'phantom_jasmine_run.js') command = "\"#{phantom_js_path}\" \"#{}\" \"#{phantom_script}\" \"#{jasmine_server_url}\" \"#{show_console_log}\" \"#{@phantom_config_script}\"" run_details = { 'random' => false } IO.popen(command) do |output| output.each do |line| if line =~ /^jasmine_spec_result/ line = line.sub(/^jasmine_spec_result/, '') raw_results = JSON.parse(line, :max_nesting => false) results = raw_results.map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) } formatter.format(results) elsif line =~ /^jasmine_suite_result/ line = line.sub(/^jasmine_suite_result/, '') raw_results = JSON.parse(line, :max_nesting => false) results = raw_results.map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) } failures = results.select(&:failed?) if failures.any? formatter.format(failures) end elsif line =~ /^jasmine_done/ line = line.sub(/^jasmine_done/, '') run_details = JSON.parse(line, :max_nesting => false) elsif line =~ /^Failed to configure phantom$/ config_failure = Result.new('fullName' => line, 'failedExpectations' => [], 'description' => '', 'status' => 'failed', 'show_full_stack_trace' => @show_full_stack_trace) formatter.format([config_failure]) @show_console_log = true puts line elsif show_console_log puts line end end end formatter.done(run_details) end |