Class: Specjour::Rspec::FinalReport

Inherits:
Object
  • Object
show all
Defined in:
lib/specjour/rspec/final_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFinalReport

Returns a new instance of FinalReport.



6
7
8
9
10
11
12
13
# File 'lib/specjour/rspec/final_report.rb', line 6

def initialize
  @duration = 0.0
  @example_count = 0
  @failure_count = 0
  @pending_count = 0
  @pending_examples = []
  @failing_examples = []
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def duration
  @duration
end

#example_countObject (readonly)

Returns the value of attribute example_count.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def example_count
  @example_count
end

#failing_examplesObject (readonly)

Returns the value of attribute failing_examples.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def failing_examples
  @failing_examples
end

#failure_countObject (readonly)

Returns the value of attribute failure_count.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def failure_count
  @failure_count
end

#pending_countObject (readonly)

Returns the value of attribute pending_count.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def pending_count
  @pending_count
end

#pending_examplesObject (readonly)

Returns the value of attribute pending_examples.



4
5
6
# File 'lib/specjour/rspec/final_report.rb', line 4

def pending_examples
  @pending_examples
end

Instance Method Details

#add(stats) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/specjour/rspec/final_report.rb', line 15

def add(stats)
  stats.each do |key, value|
    if key == :duration
      @duration = value.to_f if duration < value.to_f
    else
      increment(key, value)
    end
  end
end

#dump_failuresObject



58
59
60
61
62
# File 'lib/specjour/rspec/final_report.rb', line 58

def dump_failures
  failing_examples.each_with_index do |failure, index|
    formatter.dump_failure index + 1, failure
  end
end

#exit_statusObject



25
26
27
# File 'lib/specjour/rspec/final_report.rb', line 25

def exit_status
  failing_examples.empty?
end

#formatterObject



42
43
44
45
46
47
48
# File 'lib/specjour/rspec/final_report.rb', line 42

def formatter
  @formatter ||= begin
    f = Spec::Runner::Formatter::BaseTextFormatter.new(formatter_options, $stdout)
    f.instance_variable_set(:@pending_examples, pending_examples)
    f
  end
end

#formatter_optionsObject



34
35
36
37
38
39
40
# File 'lib/specjour/rspec/final_report.rb', line 34

def formatter_options
  @formatter_options ||= OpenStruct.new(
    :colour   => true,
    :autospec => false,
    :dry_run  => false
  )
end

#increment(key, value) ⇒ Object



29
30
31
32
# File 'lib/specjour/rspec/final_report.rb', line 29

def increment(key, value)
  current = instance_variable_get("@#{key}")
  instance_variable_set("@#{key}", current + value)
end

#summarizeObject



50
51
52
53
54
55
56
# File 'lib/specjour/rspec/final_report.rb', line 50

def summarize
  if example_count > 0
    formatter.dump_pending
    dump_failures
    formatter.dump_summary(duration, example_count, failure_count, pending_count)
  end
end