Sha256: 9e2b8735d89ee617fab3a3631a8d6d8bc3059f44141d85e6ab985c232fc2db06

Contents?: true

Size: 769 Bytes

Versions: 6

Compression:

Stored size: 769 Bytes

Contents

module Inspec::Formatters
  class RspecJson < RSpec::Core::Formatters::JsonFormatter
    RSpec::Core::Formatters.register self

    private

    # We are cheating and overriding a private method in RSpec's core JsonFormatter.
    # This is to avoid having to repeat this id functionality in both dump_summary
    # and dump_profile (both of which call format_example).
    # See https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/formatters/json_formatter.rb
    #
    # rspec's example id here corresponds to an inspec test's control name -
    # either explicitly specified or auto-generated by rspec itself.
    def format_example(example)
      res = super(example)
      res[:id] = example.metadata[:id]
      res
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/inspec/formatters/json_rspec.rb
inspec-2.1.21 lib/inspec/formatters/json_rspec.rb
inspec-2.1.10 lib/inspec/formatters/json_rspec.rb
inspec-2.0.32 lib/inspec/formatters/json_rspec.rb
inspec-2.0.17 lib/inspec/formatters/json_rspec.rb
inspec-1.51.15 lib/inspec/formatters/json_rspec.rb