Class: Spectre::JsonReporter
Instance Method Summary collapse
-
#initialize(config) ⇒ JsonReporter
constructor
A new instance of JsonReporter.
- #report(runs) ⇒ Object
Constructor Details
#initialize(config) ⇒ JsonReporter
Returns a new instance of JsonReporter.
671 672 673 674 |
# File 'lib/spectre.rb', line 671 def initialize config @out = config['stdout'] || $stdout @debug = config['debug'] end |
Instance Method Details
#report(runs) ⇒ Object
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/spectre.rb', line 676 def report runs runs = runs.select { |x| x.parent.is_a? Specification } errors = runs.count { |x| x.status == :error } failed = runs.count { |x| x.status == :failed } skipped = runs.count { |x| x.status == :skipped } succeeded = runs.count - errors - failed - skipped report = { errors: errors, failed: failed, skipped: skipped, succeeded: succeeded, runs: runs.map do |run| { spec: run.parent.name, desc: run.parent.full_desc, duration: run.finished - run.started, status: run.status, logs: run.logs, error: run.error, evaluations: run.evaluations.map do |evaluation| { desc: evaluation.desc, failures: evaluation.failures.map do |failure| { message: failure., file: failure.file, line: failure.line, } end } end } end } @out.puts JSON.dump(report) end |