Skip to content

Commit

Permalink
Ability to Send spec results in batches
Browse files Browse the repository at this point in the history
  • Loading branch information
sandro committed Feb 24, 2010
1 parent 89293de commit 5ecc370
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/specjour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
46 changes: 45 additions & 1 deletion lib/specjour/distributed_formatter.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.