Class: Specjour::Rspec::DistributedFormatter

Inherits:
Spec::Runner::Formatter::BaseTextFormatter
  • Object
show all
Defined in:
lib/specjour/rspec/distributed_formatter.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, output) ⇒ DistributedFormatter

Returns a new instance of DistributedFormatter.



13
14
15
16
17
18
19
20
21
# File 'lib/specjour/rspec/distributed_formatter.rb', line 13

def initialize(options, output)
  @options = options
  @output = output
  @failing_messages = []
  @passing_messages = []
  @pending_messages = []
  @pending_examples = []
  @failing_examples = []
end

Class Attribute Details

.batch_sizeObject

Returns the value of attribute batch_size.



6
7
8
# File 'lib/specjour/rspec/distributed_formatter.rb', line 6

def batch_size
  @batch_size
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def duration
  @duration
end

#example_countObject (readonly)

Returns the value of attribute example_count.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def example_count
  @example_count
end

#failing_examplesObject (readonly)

Returns the value of attribute failing_examples.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def failing_examples
  @failing_examples
end

#failing_messagesObject (readonly)

Returns the value of attribute failing_messages.



10
11
12
# File 'lib/specjour/rspec/distributed_formatter.rb', line 10

def failing_messages
  @failing_messages
end

#failure_countObject (readonly)

Returns the value of attribute failure_count.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def failure_count
  @failure_count
end

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/specjour/rspec/distributed_formatter.rb', line 10

def output
  @output
end

#passing_messagesObject (readonly)

Returns the value of attribute passing_messages.



10
11
12
# File 'lib/specjour/rspec/distributed_formatter.rb', line 10

def passing_messages
  @passing_messages
end

#pending_countObject (readonly)

Returns the value of attribute pending_count.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def pending_count
  @pending_count
end

#pending_examplesObject (readonly)

Returns the value of attribute pending_examples.



11
12
13
# File 'lib/specjour/rspec/distributed_formatter.rb', line 11

def pending_examples
  @pending_examples
end

#pending_messagesObject (readonly)

Returns the value of attribute pending_messages.



10
11
12
# File 'lib/specjour/rspec/distributed_formatter.rb', line 10

def pending_messages
  @pending_messages
end

Instance Method Details

#dump_failure(counter, failure) ⇒ Object



51
52
53
# File 'lib/specjour/rspec/distributed_formatter.rb', line 51

def dump_failure(counter, failure)
  failing_examples << failure
end

#dump_pendingObject



47
48
49
# File 'lib/specjour/rspec/distributed_formatter.rb', line 47

def dump_pending
  #noop
end

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/specjour/rspec/distributed_formatter.rb', line 39

def dump_summary(duration, example_count, failure_count, pending_count)
  @duration = duration
  @example_count = example_count
  @failure_count = failure_count
  @pending_count = pending_count
  output.send_message(:worker_summary=, to_hash)
end

#example_failed(example, counter, failure) ⇒ Object



23
24
25
26
# File 'lib/specjour/rspec/distributed_formatter.rb', line 23

def example_failed(example, counter, failure)
  failing_messages << colorize_failure('F', failure)
  batch_print(failing_messages)
end

#example_passed(example) ⇒ Object



28
29
30
31
# File 'lib/specjour/rspec/distributed_formatter.rb', line 28

def example_passed(example)
  passing_messages << green('.')
  batch_print(passing_messages)
end

#example_pending(example, message, deprecated_pending_location = nil) ⇒ Object



33
34
35
36
37
# File 'lib/specjour/rspec/distributed_formatter.rb', line 33

def example_pending(example, message, deprecated_pending_location=nil)
  super
  pending_messages << yellow('*')
  batch_print(pending_messages)
end

#start_dumpObject



55
56
57
58
59
# File 'lib/specjour/rspec/distributed_formatter.rb', line 55

def start_dump
  print_and_flush failing_messages
  print_and_flush passing_messages
  print_and_flush pending_messages
end

#to_hashObject



61
62
63
64
65
66
67
# File 'lib/specjour/rspec/distributed_formatter.rb', line 61

def to_hash
  h = {}
  [:duration, :example_count, :failure_count, :pending_count, :pending_examples, :failing_examples].each do |key|
    h[key] = send(key)
  end
  h
end