Sha256: a67bd8de3fb60f6fb08f1f52f85afe51d752297183e214ee2195397943743f1b

Contents?: true

Size: 1003 Bytes

Versions: 6

Compression:

Stored size: 1003 Bytes

Contents

module Opal::RSpec
  # a good compromise between not mucking with the code we're testing but making it more machine readable
  class ProgressJsonFormatter < ::RSpec::Core::Formatters::JsonFormatter
    ::RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :example_passed, :example_pending, :example_failed, :close, :stop

    def example_passed(_notification)
      output.print ::RSpec::Core::Formatters::ConsoleCodes.wrap('.', :success)
    end

    def example_pending(_notification)
      output.print ::RSpec::Core::Formatters::ConsoleCodes.wrap('*', :pending)
    end

    def example_failed(_notification)
      output.print ::RSpec::Core::Formatters::ConsoleCodes.wrap('F', :failure)
    end

    def start_dump(_notification)
      output.puts
    end

    def close(_notification)
      output.puts # our dots will not have closed out with a CR
      output.puts 'BEGIN JSON'
      super
      output.puts # Need a CR for popen to know we're done
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
opal-rspec-0.6.1 spec/rspec/shared/opal/progress_json_formatter.rb
opal-rspec-0.6.0 spec/rspec/shared/opal/progress_json_formatter.rb
opal-rspec-0.6.0.beta1 spec/rspec/shared/opal/progress_json_formatter.rb
opal-connect-rspec-0.5.0 spec/rspec/shared/opal/progress_json_formatter.rb
opal-rspec-0.5.0 spec/rspec/shared/opal/progress_json_formatter.rb
opal-rspec-0.5.0.beta3 spec/rspec/shared/opal/progress_json_formatter.rb