Sha256: a8fdd2e0b6ba5ff106a207770814c84b72cdb4dde33d7f658306543f0523c86c

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

require_relative "clipboard_formatter/version"

require 'rspec/core/formatters'
require 'clipboard'

class ClipboardFormatter
  RSpec::Core::Formatters.register self, :dump_summary

  def initialize(*)
  end

  def dump_summary(notification)
    if notification.failed_examples.present?
      locations = Hash.new{ |h,k| h[k] = [] }

      notification.failed_examples.each{ |fe|
        locations[fe.metadata[:file_path]] << fe.metadata[:line_number]
      }

      Clipboard.copy "rspec " + locations.map{ |file_path, line_numbers|
        [file_path, *line_numbers]*":"
      }*" "
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clipboard_formatter-1.0.1 lib/clipboard_formatter.rb
clipboard_formatter-1.0.0 lib/clipboard_formatter.rb