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



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

def initialize
  @examples = []
  @duration = 0.0
  ::RSpec.configuration.color_enabled = true
  ::RSpec.configuration.output_stream = $stdout
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration



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

def duration
  @duration
end

#examplesObject (readonly)

Returns the value of attribute examples



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

def examples
  @examples
end

Instance Method Details

#add(data) ⇒ Object



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

def add(data)
  if data.respond_to?(:has_key?) && data.has_key?(:duration)
    self.duration = data[:duration]
  else
    (data)
  end
end

#exit_statusObject



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

def exit_status
  formatter.failed_examples.empty?
end

#failed_examplesObject



48
49
50
# File 'lib/specjour/rspec/final_report.rb', line 48

def failed_examples
  examples.select {|e| e.execution_result[:status] == 'failed'}
end

#formatterObject



52
53
54
# File 'lib/specjour/rspec/final_report.rb', line 52

def formatter
  @formatter ||= new_progress_formatter
end

#metadata_for_examples(metadata_collection) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/specjour/rspec/final_report.rb', line 29

def ()
  examples.concat(
    .map do ||
      example = ::RSpec::Core::Example.allocate
      example.instance_variable_set(:@example_group_class,
        OpenStruct.new(:metadata => {}, :ancestors => [])
      )
       = ::RSpec::Core::Metadata.new
      .merge! 
      example.instance_variable_set(:@metadata, )
      example
    end
  )
end

#pending_examplesObject



44
45
46
# File 'lib/specjour/rspec/final_report.rb', line 44

def pending_examples
  examples.select {|e| e.execution_result[:status] == 'pending'}
end

#summarizeObject



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

def summarize
  if examples.size > 0
    formatter.start_dump
    formatter.dump_pending
    formatter.dump_failures
    formatter.dump_summary(duration, examples.size, failed_examples.size, pending_examples.size)
  end
end