Sha256: 4650d421a00b424111b8b274a0104dc0547c85fb35dad53c2b6f745a8195d34f

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 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 => e
    puts e
    puts e.backtrace
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
test_notifier-2.0.3 lib/test_notifier/runner/autotest.rb
test_notifier-2.0.2 lib/test_notifier/runner/autotest.rb
test_notifier-2.0.1 lib/test_notifier/runner/autotest.rb
test_notifier-2.0.0 lib/test_notifier/runner/autotest.rb
test_notifier-1.0.1 lib/test_notifier/runner/autotest.rb
test_notifier-1.0.0 lib/test_notifier/runner/autotest.rb
test_notifier-0.4.0 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.6 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.5 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.5.rc.4 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.5.rc.3 lib/test_notifier/runner/autotest.rb
test_notifier-0.3.5.rc.2 lib/test_notifier/runner/autotest.rb