class RSpecLive::Runner
Public Class Methods
new()
click to toggle source
# File lib/rspec-live/runner.rb, line 6 def initialize @queued_examples = [] @results = [] end
Public Instance Methods
request_inventory(status)
click to toggle source
# File lib/rspec-live/runner.rb, line 11 def request_inventory(status) @inventory_requested = status end
request_results(examples)
click to toggle source
# File lib/rspec-live/runner.rb, line 15 def request_results(examples) @queued_examples = examples return if @queued_examples.empty? end
results()
click to toggle source
# File lib/rspec-live/runner.rb, line 20 def results start_process unless @process && @process.running? @process.each_line { |line| record_result line } if @process @results.pop @results.length end
Private Instance Methods
formatter_class(formatter)
click to toggle source
# File lib/rspec-live/runner.rb, line 58 def formatter_class(formatter) "#{formatter.capitalize}Formatter" end
formatter_command(formatter, options)
click to toggle source
# File lib/rspec-live/runner.rb, line 48 def formatter_command(formatter, options) options << " --format #{formatter_class formatter}" options << " --require #{formatter_source formatter}" "rspec #{options}" end
formatter_source(formatter)
click to toggle source
# File lib/rspec-live/runner.rb, line 54 def formatter_source(formatter) File.join File.dirname(__FILE__), "../formatters/#{formatter}_formatter.rb" end
record_result(text)
click to toggle source
# File lib/rspec-live/runner.rb, line 28 def record_result(text) @results << JSON.parse(text) rescue JSON::ParserError end
run(formatter, options="", &block)
click to toggle source
# File lib/rspec-live/runner.rb, line 43 def run(formatter, options="", &block) @process = ConcurrentProcess.new formatter_command(formatter, options) @process.start end
start_process()
click to toggle source
# File lib/rspec-live/runner.rb, line 33 def start_process if @inventory_requested run "inventory", "--dry-run" @inventory_requested = false elsif @queued_examples.any? run "update", @queued_examples.join(" ") @queued_examples = [] end end