Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display notification only on fail as an option? #134

Open
Fedcomp opened this issue Nov 29, 2015 · 2 comments
Open

Display notification only on fail as an option? #134

Fedcomp opened this issue Nov 29, 2015 · 2 comments

Comments

@Fedcomp
Copy link

Fedcomp commented Nov 29, 2015

Could be there option to display notification only when tests fail?
Right now it spams me with every running, even if tests are not failing.

@e2
Copy link
Contributor

e2 commented Nov 29, 2015

I don't use notification myself, but I'm guessing people use notification to know "if tests finished".

But it seems useful to opt out.

I don't know what notification backend you're using (depends on your OS and settings), but I think this could be a generic feature.

If you like, you can quickly hack a solution yourself and then send a PR if it works.

I'm not sure what kind of API/configuration would be best, but let's say it's:

notification(:tmux, {
  ignored_notifications: [:success] # < ---- maybe an option like this?
  success: 'colour150',
  failure: 'colour174',
  pending: 'colour179',
}) if ENV['TMUX']

And then in:

https://github.com/guard/notiffany/blob/fc138bb63ed94d754a0091a3813d3938db3c41a5/lib/notiffany/notifier/base.rb#L72

You'd skip the _perform_notify if the current notification type is in the "ignored" list.

@polarlights
Copy link

As I use minitest-reporter gem, I made a monkey patch in my test_helper.rb file.

module NofityFailureTest
  def record(test)
    super

    if test.error? || test.failure
      e = test.failure
      TerminalNotifier::Guard.notify(e.message, title: File.basename(e.location))
    end
  end
end

module Minitest
  module Reporters
    class  BaseReporter
      include NofityFailureTest if RUBY_PLATFORM =~ /darwin/ && `which terminal-notifier`.present?
    end
  end
end

You can monkey patch minitest gem If you like. It's in Minitest::Reporters::BaseReporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants