Permalink
Browse files

Ability to Send spec results in batches

  • Loading branch information...
1 parent 89293de commit 5ecc37050ad6bac156b1152f639e1d8d84cf3972 @sandro sandro committed Feb 24, 2010
Showing with 46 additions and 2 deletions.
  1. +1 −1 lib/specjour.rb
  2. +45 −1 lib/specjour/distributed_formatter.rb
View
@@ -4,7 +4,7 @@
require 'dnssd'
require 'forwardable'
require 'spec'
-require 'spec/runner/formatter/progress_bar_formatter'
+require 'spec/runner/formatter/base_text_formatter'
require 'specjour/marshalable_rspec_failure'
@@ -1,5 +1,32 @@
module Specjour
- class DistributedFormatter < Spec::Runner::Formatter::ProgressBarFormatter
+ class DistributedFormatter < Spec::Runner::Formatter::BaseTextFormatter
+ BATCH = 1
+
+ attr_reader :failing_messages, :passing_messages, :pending_messages
+
+ def initialize(options, output)
+ @failing_messages = []
+ @passing_messages = []
+ @pending_messages = []
+ super
+ end
+
+ def example_failed(example, counter, failure)
+ failing_messages << colorize_failure('F', failure)
+ batch_print(failing_messages)
+ end
+
+ def example_passed(example)
+ passing_messages << green('.')
+ batch_print(passing_messages)
+ end
+
+ def example_pending(example, message, deprecated_pending_location=nil)
+ super
+ pending_messages << yellow('*')
+ batch_print(pending_messages)
+ end
+
def dump_summary(*args)
@output.add_to_summary(*args)
end
@@ -13,6 +40,23 @@ def dump_failure(counter, failure)
end
def start_dump
+ print_and_flush failing_messages
+ print_and_flush passing_messages
+ print_and_flush pending_messages
+ end
+
+ protected
+
+ def batch_print(messages)
+ if messages.size == BATCH
+ print_and_flush(messages)
+ end
+ end
+
+ def print_and_flush(messages)
+ @output.print messages.join('')
+ @output.flush
+ messages.clear
end
end
end

0 comments on commit 5ecc370

Please sign in to comment.