Class: RSpec::Core::Formatters::JsonFormatter Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
BaseFormatter
|
|
Instance Chain:
self,
BaseFormatter
|
|
Inherits: |
RSpec::Core::Formatters::BaseFormatter
|
Defined in: | rspec-core/lib/rspec/core/formatters/json_formatter.rb |
Class Method Summary
Instance Attribute Summary
Instance Method Summary
- #close(_notification) Internal use only
- #dump_profile(profile) Internal use only
- #dump_profile_slowest_example_groups(profile) Internal use only
- #dump_profile_slowest_examples(profile) Internal use only
- #dump_summary(summary) Internal use only
- #message(notification) Internal use only
- #seed(notification) Internal use only
- #stop(group_notification) Internal use only
- #format_example(example) private Internal use only
BaseFormatter
- Inherited
Instance Attribute Details
#output_hash (readonly)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 11
attr_reader :output_hash
Instance Method Details
#close(_notification)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 56
def close(_notification) output.write @output_hash.to_json end
#dump_profile(profile)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 60
def dump_profile(profile) @output_hash[:profile] = {} dump_profile_slowest_examples(profile) dump_profile_slowest_example_groups(profile) end
#dump_profile_slowest_example_groups(profile)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 79
def dump_profile_slowest_example_groups(profile) @output_hash[:profile] ||= {} @output_hash[:profile][:groups] = profile.slowest_groups.map do |loc, hash| hash.update(:location => loc) end end
#dump_profile_slowest_examples(profile)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 67
def dump_profile_slowest_examples(profile) @output_hash[:profile] = {} @output_hash[:profile][:examples] = profile.slowest_examples.map do |example| format_example(example).tap do |hash| hash[:run_time] = example.execution_result.run_time end end @output_hash[:profile][:slowest] = profile.slow_duration @output_hash[:profile][:total] = profile.duration end
#dump_summary(summary)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 24
def dump_summary(summary) @output_hash[:summary] = { :duration => summary.duration, :example_count => summary.example_count, :failure_count => summary.failure_count, :pending_count => summary.pending_count, :errors_outside_of_examples_count => summary.errors_outside_of_examples_count } @output_hash[:summary_line] = summary.totals_line end
#format_example(example) (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 88
def format_example(example) { :id => example.id, :description => example.description, :full_description => example.full_description, :status => example.execution_result.status.to_s, :file_path => example. [:file_path], :line_number => example. [:line_number], :run_time => example.execution_result.run_time, : => example.execution_result., } end
#message(notification)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 20
def (notification) (@output_hash[: ] ||= []) << notification. end
#seed(notification)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 51
def seed(notification) return unless notification.seed_used? @output_hash[:seed] = notification.seed end
#stop(group_notification)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/json_formatter.rb', line 35
def stop(group_notification) @output_hash[:examples] = group_notification.notifications.map do |notification| format_example(notification.example).tap do |hash| e = notification.example.exception if e hash[:exception] = { :class => e.class.name, : => e., :backtrace => notification.formatted_backtrace, } end end end end