Sha256: 648c4838341f155108a772d09db550ebd5d24f871706a252375bb1f2a1d84c26

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 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

      stats = TestNotifier::Stats.new(:spec, {
        :count    => examples,
        :failures => failures,
        :pending  => pending
      })

      TestNotifier.notify(:status => stats.status, :message => stats.message) unless examples.to_i.zero?
    elsif test_unit_matches
      _, tests, assertions, failures, errors = *test_unit_matches

      stats = TestNotifier::Stats.new(:test_unit, {
        :count      => tests,
        :assertions => assertions,
        :failures   => failures,
        :errors     => errors
      })

      TestNotifier.notify(:status => stats.status, :message => stats.message) unless tests.to_i.zero?
    end
  rescue
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_notifier-0.3.5.rc.1 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.4 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.3 lib/test_notifier/runner/autotest.rb