Customize Minitest output to growl

47 Views Asked by At

In my rails app I am using:

  • guard
  • guard-minitest
  • growl

when a test runs in the background:

enter image description here

I get this from Growl:

enter image description here

Great to know that at least one test failed. Any way to add that summary that reports the number i.e. 2 failures etc.?

1

There are 1 best solutions below

3
max On BEST ANSWER

You can change the behavior by modifying Guard::Minitest::Notifier.notify:

require 'guard/compat/plugin'

module Guard
  class Minitest < Plugin
    class Notifier
      # ...
      def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
        message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
        image   = guard_image(failure_count + error_count, skip_count)

        # title: was just 'Minitest results'
        Compat::UI.notify(message, title: message, image: image)
      end
    end
  end
end

The title 'Minitest results' is most likely just a cludged placeholder. This example sets it to the same output as you get in the CLI but you can really do whatever you want here.

You would preferably do this by forking the gem and setting your gemfile to pull from your fork.

gem 'minitest-guard', github: 'yourusername/minitest-guard'