require 'rspec/core/formatters/base_text_formatter'

module RSpec
  module Core
    module Formatters
      class AugmentedTextFormatter < BaseTextFormatter
        def initialize(output)
          super(output)
        end

        def self.configure buffet_server, slave_name
          @@buffet_server = buffet_server
          @@slave_name = slave_name
        end

        def example_passed example
          super
          @@buffet_server.example_passed(@@slave_name, {
            :description => example.description,
            :location    => example.location,
            :slave_name  => @@slave_name,
          })
        end

        def example_failed example
          super
          exception = example.metadata[:execution_result][:exception]
          backtrace = format_backtrace(exception.backtrace, example).join("\n")

          message = exception.message
          if shared_group = find_shared_group(example)
            message += "\nShared example group called from " +
              backtrace_line(shared_group.metadata[:example_group][:location])
          end

          @@buffet_server.example_failed(@@slave_name, {
            :description => example.description,
            :backtrace   => backtrace,
            :message     => message,
            :location    => example.location,
            :slave_name  => @@slave_name,
          })
        end

        def example_pending example
          super
          @@buffet_server.example_pending(@@slave_name, {
            :description => example.description,
            :location    => example.location,
            :slave_name  => @@slave_name,
          })
        end
      end
    end
  end
end

require 'rspec/core/formatters/base_text_formatter'

module RSpec
  module Core
    module Formatters
      class AugmentedTextFormatter < BaseTextFormatter
        def initialize(output)
          super(output)
        end

        def self.configure buffet_server, slave_name
          @@buffet_server = buffet_server
          @@slave_name = slave_name
        end

        def example_passed example
          super
          @@buffet_server.example_passed(@@slave_name, {
            :description => example.description,
            :location    => example.location,
            :slave_name  => @@slave_name,
          })
        end

        def example_failed example
          super
          exception = example.metadata[:execution_result][:exception]
          backtrace = format_backtrace(exception.backtrace, example).join("\n")

          location = example.location
          if shared_group = find_shared_group(example)
            location += "\nShared example group called from " +
              backtrace_line(shared_group.metadata[:example_group][:location])
          end

          @@buffet_server.example_failed(@@slave_name, {
            :description => example.description,
            :backtrace   => backtrace,
            :message     => exception.message,
            :location    => location,
            :slave_name  => @@slave_name,
          })
        end

        def example_pending example
          super
          @@buffet_server.example_pending(@@slave_name, {
            :description => example.description,
            :location    => example.location,
            :slave_name  => @@slave_name,
          })
        end
      end
    end
  end
end

Append failed shared example info to location, not message
Append failed shared example info to location, not message

Shared example caller info was being displayed at the end of failure
output, which can be confusing when there are multiple failures.

Append the info to the location string instead, which seems more
sensible anyway.

Change-Id: I93dd5b7d8fffa73b5d99d2c3df66db415954331c
Reviewed-on: https://gerrit.causes.com/11961
Tested-by: Lann Martin <564fa7a717c51b612962ea128f146981a0e99d90@causes.com>
Reviewed-by: Aiden Scandella <1faf1e8390cdac9204f160c35828cc423b7acd7b@causes.com>
