Sha256: f013c3f87af3b90103be1c76e562248331da96203da8548207bc938badd96fbf
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
class JSpecTask def initialize(jspec) @jspec = jspec end def run(files) all_files = files[:all] modified_files = files[:filtered] return nil if (!@jspec.is_configured? all_files) return nil if (!@jspec.should_run? modified_files) detail = @jspec.execute state, summary, first = parse_results(detail) return { :state => state, :title => 'JSpec', :summary => summary, :first => first, :detail => detail } end def parse_results(detail) summary_line = detail.grep( /Passes:/ )[0] if summary_line.nil? # error error_info = (detail + "\nUnknown Error!").to_a[0] return :error, 'Error', error_info end # remove console colour information and trim start and end white space summary_line = remove_colour(summary_line).strip if summary_line =~ /Failures:\s+([1-9]+)\d*/ num_failures = $1 error_line = detail.grep(/\[31m/)[1] || '' error_info = remove_colour(error_line).strip return :failure, num_failures + ' Failures', error_info end return :success, 'All Passed', summary_line end def remove_colour(string) return string.gsub(/\e\[[0-9]+m?/, '') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
karl-loris-0.0.9 | lib/tasks/jspec/jspec_task.rb |