Sha256: 5f47c032981fffa99e83e1cbb8ae19ec4de0abf7d5efbd4e880fbf9ab31e2a95

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require "test_notifier"

Autotest.add_hook :ran_command do |at|
  begin
    content = at.results.to_s

    rspec_matches = content.match(/(\d+) examples?, (\d+) failures?(, (\d+) pendings?)?/)
    test_unit_matches = content.match(/(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/)

    if rspec_matches
      _, examples, failures, _, pending = *rspec_matches
      status = failures.to_i > 0 ? :fail : :success
      message = "#{examples} examples, #{failures} failed"
      message << ", #{pending} pending" if pending
      TestNotifier.notify(:status => status, :message => message) unless examples.to_i.zero?
    elsif test_unit_matches
      _, tests, assertions, failures, errors = *test_unit_matches

      if errors.to_i.nonzero?
        status = :error
      elsif failures.to_i.nonzero?
        status = :fail
      else
        status = :success
      end

      message = "#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors"
      TestNotifier.notify(:status => status, :message => message) unless tests.to_i.zero?
    end
  rescue
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_notifier-0.3.1 lib/test_notifier/runner/autotest.rb