Class: Fluff::Rspec::Formatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- Fluff::Rspec::Formatter
- Defined in:
- lib/fluff/rspec/formatter.rb
Instance Attribute Summary collapse
-
#output_hash ⇒ Object
readonly
Returns the value of attribute output_hash.
Instance Method Summary collapse
- #close(_notification) ⇒ Object
- #dump_summary(summary) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(output) ⇒ Formatter
constructor
A new instance of Formatter.
- #message(notification) ⇒ Object
- #seed(notification) ⇒ Object
- #start(notification) ⇒ Object
Constructor Details
#initialize(output) ⇒ Formatter
Returns a new instance of Formatter.
13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#output_hash ⇒ Object (readonly)
Returns the value of attribute output_hash.
11 12 13 |
# File 'lib/fluff/rspec/formatter.rb', line 11 def output_hash @output_hash end |
Instance Method Details
#close(_notification) ⇒ Object
60 61 62 |
# File 'lib/fluff/rspec/formatter.rb', line 60 def close(_notification) emit @summary_hash end |
#dump_summary(summary) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# 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) ⇒ Object
33 34 35 |
# File 'lib/fluff/rspec/formatter.rb', line 33 def example_failed(notification) emit format_example(notification.example) end |
#example_passed(notification) ⇒ Object
29 30 31 |
# File 'lib/fluff/rspec/formatter.rb', line 29 def example_passed(notification) emit format_example(notification.example) end |
#example_pending(notification) ⇒ Object
37 38 39 |
# File 'lib/fluff/rspec/formatter.rb', line 37 def example_pending(notification) emit format_example(notification.example) end |
#message(notification) ⇒ Object
41 42 43 |
# File 'lib/fluff/rspec/formatter.rb', line 41 def (notification) emit :type => 'message', :message => notification. end |
#seed(notification) ⇒ Object
55 56 57 58 |
# File 'lib/fluff/rspec/formatter.rb', line 55 def seed(notification) return unless notification.seed_used? @summary_hash[:seed] = notification.seed end |
#start(notification) ⇒ Object
20 21 22 23 24 25 26 27 |
# 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 |