class Fluff::Rspec::Formatter
Attributes
output_hash[R]
Public Class Methods
new(output)
click to toggle source
Calls superclass method
# File lib/fluff/rspec/formatter.rb, line 13 def initialize(output) super @run_uuid = ENV.fetch('FLUFF_RUN_UUID', SecureRandom.uuid) @summary_hash = {} @redis = Redis.new(url: ENV.fetch('FLUFF_REDIS_URL')) end
Public Instance Methods
close(_notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 60 def close(_notification) emit @summary_hash end
dump_summary(summary)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 45 def dump_summary(summary) @summary_hash.merge!( :type => 'summary', :duration => summary.duration, :example_count => summary.example_count, :failure_count => summary.failure_count, :pending_count => summary.pending_count ) end
example_failed(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 33 def example_failed(notification) emit format_example(notification.example) end
example_passed(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 29 def example_passed(notification) emit format_example(notification.example) end
example_pending(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 37 def example_pending(notification) emit format_example(notification.example) end
message(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 41 def message(notification) emit :type => 'message', :message => notification.message end
seed(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 55 def seed(notification) return unless notification.seed_used? @summary_hash[:seed] = notification.seed end
start(notification)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 20 def start(notification) emit( :type => 'start', :version => RSpec::Core::Version::STRING, :project_path => (defined?(Rails) ? Rails.root.to_s : Dir.pwd), :lib_paths => Gem.loaded_specs.map { |gem_name, gem_spec| [gem_name, gem_spec.full_gem_path] } ) end
Private Instance Methods
emit(payload)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 66 def emit(payload) payload = { :run_uuid => @run_uuid }.merge(payload) # puts JSON.pretty_generate(payload) @redis.publish "fluff_shouts", JSON.generate(payload) end
format_example(example)
click to toggle source
# File lib/fluff/rspec/formatter.rb, line 72 def format_example(example) payload = { :type => 'example_result', :id => example.id, :description => example.description, :full_description => example.full_description, :status => example.execution_result.status.to_s, :file_path => example.metadata[:file_path], :line_number => example.metadata[:line_number], :run_time => example.execution_result.run_time, :pending_message => example.execution_result.pending_message, } if (e = example.exception) payload[:exception] = { :class => e.class.name, :message => e.message, :backtrace => e.backtrace, } end payload end