Sha256: 0a499a14ef962b85a503be0268d31ff6c76311ece6f4e6c848aa5370f0953e06

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require 'rspec/core/formatters/base_formatter'
require 'terminal-notifier'

class Nc < RSpec::Core::Formatters::BaseFormatter
  SUCCESS_EMOJI = "\u2705"
  FAILURE_EMOJI = "\u26D4"

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

  def dump_summary(notification)
    body = "Finished in #{notification.formatted_duration}\n#{notification.totals_line}"
    title = if notification.failure_count > 0
      "#{FAILURE_EMOJI} #{directory_name}: #{notification.failure_count} failed example#{notification.failure_count == 1 ? nil : 's'}"
    else
      "#{SUCCESS_EMOJI} #{directory_name}: Success"
    end
    TerminalNotifier.notify body, title: title
  end

  private

  def directory_name
    File.basename File.expand_path '.'
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/rspec-nc-0.3.0/lib/nc.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/rspec-nc-0.3.0/lib/nc.rb
rspec-nc-0.3.0 lib/nc.rb