Class: Specjour::RSpec::FinalReport
- Inherits:
-
Object
- Object
- Specjour::RSpec::FinalReport
- Defined in:
- lib/specjour/rspec/final_report.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
Instance Method Summary collapse
- #add(data) ⇒ Object
- #exit_status ⇒ Object
- #failed_examples ⇒ Object
- #formatter ⇒ Object
-
#initialize ⇒ FinalReport
constructor
A new instance of FinalReport.
- #metadata_for_examples(metadata_collection) ⇒ Object
- #pending_examples ⇒ Object
- #summarize ⇒ Object
Constructor Details
#initialize ⇒ FinalReport
Returns a new instance of FinalReport.
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
#duration ⇒ Object
Returns the value of attribute duration.
4 5 6 |
# File 'lib/specjour/rspec/final_report.rb', line 4 def duration @duration end |
#examples ⇒ Object (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_status ⇒ Object
25 26 27 |
# File 'lib/specjour/rspec/final_report.rb', line 25 def exit_status formatter.failed_examples.empty? end |
#failed_examples ⇒ Object
48 49 50 |
# File 'lib/specjour/rspec/final_report.rb', line 48 def failed_examples examples.select {|e| e.execution_result[:status] == 'failed'} end |
#formatter ⇒ Object
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 => [], :parent_groups => []) ) = ::RSpec::Core::Metadata.new .merge! example.instance_variable_set(:@metadata, ) example end ) end |
#pending_examples ⇒ Object
44 45 46 |
# File 'lib/specjour/rspec/final_report.rb', line 44 def pending_examples examples.select {|e| e.execution_result[:status] == 'pending'} end |
#summarize ⇒ Object
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 |