test_notifier 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48e80e39f269e2232354733498a32f2752e2d119786f5e6ed3694010194c006d
4
- data.tar.gz: e24235a4358017441c12aab610ace1b43bfbaab5b65c899c3e128af53b9f7edf
3
+ metadata.gz: a4b46a9c384eb5f3be2092410e47fc46908be2cb8d43cf91921ad77b414b8ed3
4
+ data.tar.gz: 0faba90248d756a52211df5e83553256e15996e0e092729a63cac91d6a9b803c
5
5
  SHA512:
6
- metadata.gz: 80664726eaaa82e62db4970584a1cbe95246c2142ea09e88d0d8fbc8de438b1420ae9ad270f05d90a3d5d2c2543165942957915ef2f56114efbfa66605719179
7
- data.tar.gz: 929599d9ea690c9e9bf7e189ce42c735abf9d83f961b16c70a3d1967053d516deb6d18bea39a212e4cd74412ff4b1e9669f0d41c85ef9920d6faea0ec4b96828
6
+ metadata.gz: aac8c5ae3acc691ee740a4db73fa09a18d440e89d5532c11b57563e5bf98681ac1d12470faa1f570155969a2a5b88d2538deddae6fe6461565ffaef88966a654
7
+ data.tar.gz: fc03272885566e612f757b21dba81f6297e7fc6907ab61b60b675b6ce2628cec2b263edac21a8adc186daf6c0de08c5e73a29906f3216c6965f2d1ae16a64b03
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  pkg
3
3
  nbproject
4
4
  *.lock
5
+ hud.xcworkspace/xcuserdata
data/.rubocop.yml CHANGED
@@ -3,7 +3,11 @@ inherit_gem:
3
3
  rubocop-fnando: .rubocop.yml
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.4
7
7
  NewCops: enable
8
8
  Exclude:
9
9
  - vendor/**/*
10
+
11
+ Minitest/UselessAssertion:
12
+ Exclude:
13
+ - test/fixtures/*
data/README.md CHANGED
@@ -1,16 +1,6 @@
1
1
  # Test Notifier
2
2
 
3
- Inspired by
4
- http://railstips.org/2007/7/23/autotest-growl-pass-fail-notifications
5
-
6
- After using Growl notification, I decided to write my own plugin because I have
7
- to work on Ubuntu and Mac OS X and I missed the notification on my Linux box.
8
- This plugin works with Linux, Mac OS X and Windows. All you need to do is
9
- install the specific notification library for your OS.
10
-
11
- Instead of displaying lots of notifications for each failure, I prefer to be
12
- notified about the whole test result (you'll have to check your log file anyway
13
- in order to clean up the failures/errors).
3
+ Display notifications when tests run. Supports Minitest and RSpec.
14
4
 
15
5
  ## Installation
16
6
 
@@ -23,20 +13,7 @@ notifier for your OS.
23
13
 
24
14
  ## Usage
25
15
 
26
- If you're using Test::Unit you should add
27
- `require "test_notifier/runner/test_unit"` to your `test_helper.rb` file.
28
-
29
- If you're using RSpec you should add `require "test_notifier/runner/spec"` to
30
- your `spec_helper.rb` file. If you're using RSpec 2-3, you need to add
31
- `require "test_notifier/runner/rspec"` instead.
32
-
33
- If you're using Autotest you should add
34
- `require "test_notifier/runner/autotest"` to the file `~/.autotest`
35
-
36
- If you're using MiniTest you should add
37
- `require "test_notifier/runner/minitest"` to your `test_helper.rb` file.
38
-
39
- You can define your notifier.
16
+ You can set the default notifier, in case you want to use an specific one.
40
17
 
41
18
  ```ruby
42
19
  TestNotifier.default_notifier = :terminal_notifier
data/Rakefile CHANGED
@@ -3,10 +3,17 @@
3
3
  require "bundler"
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
- require "rspec/core/rake_task"
7
- RSpec::Core::RakeTask.new
6
+ # require "rspec/core/rake_task"
7
+ # RSpec::Core::RakeTask.new
8
+
9
+ require "rake/testtask"
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << "test"
12
+ t.test_files = FileList["test/**/*_test.rb"]
13
+ t.warning = false
14
+ end
8
15
 
9
16
  require "rubocop/rake_task"
10
17
  RuboCop::RakeTask.new
11
18
 
12
- task default: %i[spec rubocop]
19
+ task default: %i[test rubocop]
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Minitest
4
+ def self.plugin_test_notifier_init(_options)
5
+ reporter << TestNotifier::MinitestReporter.new
6
+ end
7
+ end
@@ -1,17 +1,64 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "test_notifier"
4
- require "minitest/unit"
4
+ require "minitest"
5
5
 
6
- MiniTest::Unit.after_tests do
7
- runner = MiniTest::Unit.runner
6
+ module TestNotifier
7
+ class MinitestReporter < Minitest::AbstractReporter
8
+ attr_reader :count, :assertions, :failures, :errors, :pending
8
9
 
9
- stats = TestNotifier::Stats.new(:minitest, {
10
- count: runner.test_count,
11
- assertions: runner.assertion_count,
12
- failures: runner.failures,
13
- errors: runner.errors
14
- })
10
+ def initialize(*)
11
+ super
12
+ @assertions = 0
13
+ @count = 0
14
+ @failures = 0
15
+ @errors = 0
16
+ @pending = 0
17
+ end
15
18
 
16
- TestNotifier.notify(status: stats.status, message: stats.message)
19
+ def start
20
+ end
21
+
22
+ def prerecord(*)
23
+ end
24
+
25
+ def record(result)
26
+ flunked = result.failures.count { flunk?(it) }
27
+
28
+ @count += 1
29
+ @assertions += result.assertions
30
+ @assertions -= flunked if flunked.nonzero?
31
+ @errors += result.failures.count { error?(it) }
32
+ @failures += result.failures.count { failure?(it) }
33
+ @pending += flunked
34
+ end
35
+
36
+ def flunk?(failure)
37
+ (failure.backtrace_locations || [])
38
+ .any? { it.label == "Minitest::Assertions#flunk" }
39
+ end
40
+
41
+ def failure?(failure)
42
+ failure.is_a?(Minitest::Assertion) && !flunk?(failure)
43
+ end
44
+
45
+ def error?(failure)
46
+ failure.is_a?(Minitest::UnexpectedError)
47
+ end
48
+
49
+ def report
50
+ stats = TestNotifier::Stats.new(
51
+ :minitest,
52
+ count:,
53
+ assertions:,
54
+ failures:,
55
+ errors:,
56
+ pending:
57
+ )
58
+
59
+ TestNotifier.notify(status: stats.status, message: stats.message)
60
+ end
61
+ end
17
62
  end
63
+
64
+ Minitest.load(:test_notifier)
@@ -1,9 +1,49 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rspec/core/version"
3
+ require "test_notifier"
4
+ require "rspec/core"
5
+ require "rspec/core/formatters/base_text_formatter"
4
6
 
5
- if RSpec::Core::Version::STRING >= "3.0.0"
6
- require "test_notifier/runner/rspec3"
7
- else
8
- require "test_notifier/runner/rspec2"
7
+ module RSpec
8
+ module Core
9
+ module Formatters
10
+ class BaseTextFormatter
11
+ alias dump_summary_original dump_summary
12
+
13
+ def error_filter
14
+ proc do |error|
15
+ error.exception.is_a?(UncaughtThrowError)
16
+ end
17
+ end
18
+
19
+ def failure_filter
20
+ proc do |error|
21
+ error.exception
22
+ .instance_of?(RSpec::Expectations::ExpectationNotMetError)
23
+ end
24
+ end
25
+
26
+ def dump_summary(options)
27
+ dump_summary_original(options)
28
+
29
+ count = options.example_count
30
+ pending = options.pending_count
31
+ errors = options.failed_examples.count(&error_filter)
32
+ failures = options.failed_examples.size - errors
33
+
34
+ return if count.zero?
35
+
36
+ stats = TestNotifier::Stats.new(
37
+ :rspec,
38
+ count:,
39
+ failures:,
40
+ pending:,
41
+ errors:
42
+ )
43
+
44
+ TestNotifier.notify(status: stats.status, message: stats.message)
45
+ end
46
+ end
47
+ end
48
+ end
9
49
  end
@@ -3,7 +3,6 @@
3
3
  module TestNotifier
4
4
  module Runner
5
5
  autoload :RSpec, "test_notifier/runner/rspec"
6
- autoload :Spec, "test_notifier/runner/spec"
7
- autoload :TestUnit, "test_notifier/runner/test_unit"
6
+ autoload :Minitest, "test_notifier/runner/minitest"
8
7
  end
9
8
  end
@@ -20,32 +20,10 @@ module TestNotifier
20
20
  end
21
21
 
22
22
  private def normalize(options)
23
- %i[
24
- count success failures pending errors
25
- assertions
26
- ].each_with_object({}) do |key, buffer|
27
- buffer[key] = options[key].to_i
28
- end
29
- end
30
-
31
- private def status_for_minitest
32
- if options[:errors].nonzero?
33
- :error
34
- elsif options[:failures].nonzero?
35
- :fail
36
- else
37
- :success
38
- end
39
- end
40
-
41
- private def status_for_test_unit
42
- if options[:errors].nonzero?
43
- :error
44
- elsif options[:failures].nonzero?
45
- :fail
46
- else
47
- :success
48
- end
23
+ %i[count success failures pending errors assertions]
24
+ .each_with_object({}) do |key, buffer|
25
+ buffer[key] = options[key].to_i
26
+ end
49
27
  end
50
28
 
51
29
  private def status_for_rspec
@@ -58,14 +36,6 @@ module TestNotifier
58
36
  end
59
37
  end
60
38
 
61
- private def status_for_spec
62
- if options[:failures].nonzero?
63
- :fail
64
- else
65
- :success
66
- end
67
- end
68
-
69
39
  private def message_for_rspec
70
40
  options[:success] =
71
41
  options[:count] - (options[:failures] + options[:errors])
@@ -81,25 +51,14 @@ module TestNotifier
81
51
  text.join(", ")
82
52
  end
83
53
 
84
- private def message_for_spec
85
- text = []
86
- text << ("#{options[:count]} " + pluralize(options[:count], "example"))
87
- text << "#{options[:failures]} failed" unless options[:failures].zero?
88
- text << "#{options[:pending]} pending" unless options[:pending].zero?
89
- text.join(", ")
90
- end
91
-
92
- private def message_for_test_unit
93
- text = []
94
- text << ("#{options[:count]} " + pluralize(options[:count], "test"))
95
- text << ("#{options[:assertions]} " + pluralize(options[:assertions],
96
- "assertion"))
97
- text << "#{options[:failures]} failed" unless options[:failures].zero?
98
- unless options[:errors].zero?
99
- text << ("#{options[:errors]} " + pluralize(options[:errors],
100
- "error"))
54
+ private def status_for_minitest
55
+ if options[:errors].nonzero?
56
+ :error
57
+ elsif options[:failures].nonzero?
58
+ :fail
59
+ else
60
+ :success
101
61
  end
102
- text.join(", ")
103
62
  end
104
63
 
105
64
  private def message_for_minitest
@@ -108,15 +67,19 @@ module TestNotifier
108
67
  text << ("#{options[:assertions]} " + pluralize(options[:assertions],
109
68
  "assertion"))
110
69
  text << "#{options[:failures]} failed" unless options[:failures].zero?
70
+
111
71
  unless options[:errors].zero?
112
72
  text << ("#{options[:errors]} " + pluralize(options[:errors],
113
73
  "error"))
114
74
  end
75
+
76
+ text << "#{options[:pending]} pending" unless options[:pending].zero?
77
+
115
78
  text.join(", ")
116
79
  end
117
80
 
118
81
  private def pluralize(count, text)
119
- count > 1 ? "#{text}s" : text
82
+ count == 1 ? text : "#{text}s"
120
83
  end
121
84
  end
122
85
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  module TestNotifier
4
4
  module Version
5
- MAJOR = 2
6
- MINOR = 1
5
+ MAJOR = 3
6
+ MINOR = 0
7
7
  PATCH = 0
8
- STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}".freeze
9
9
  end
10
10
  end
data/lib/test_notifier.rb CHANGED
@@ -16,7 +16,7 @@ module TestNotifier
16
16
 
17
17
  HUD_SYMBOLS = {
18
18
  fail: "exclamationmark.triangle",
19
- error: "xmark.octagon.fill",
19
+ error: "xmark.octagon",
20
20
  success: "checkmark.circle"
21
21
  }.freeze
22
22
 
@@ -55,13 +55,14 @@ module TestNotifier
55
55
  def notifier
56
56
  notifier = Notifier.notifier
57
57
 
58
- if notifier == Notifier::Placebo && !silence_no_notifier_warning
58
+ if notifier == Notifier::Noop && !silence_no_notifier_warning
59
59
  $stderr << NO_NOTIFIERS_MESSAGE
60
60
  end
61
61
 
62
62
  notifier
63
63
  end
64
64
 
65
- require "test_notifier/runner"
66
65
  require "test_notifier/stats"
66
+ require "test_notifier/runner/minitest" if defined?(Minitest)
67
+ require "test_notifier/runner/rspec" if defined?(RSpec)
67
68
  end
data/resources/error.png CHANGED
Binary file
data/resources/fail.png CHANGED
Binary file
Binary file
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "minitest/autorun"
5
+ require "test_notifier"
6
+
7
+ class MinitestSample < Minitest::Test
8
+ def test_passes
9
+ assert true
10
+ assert true
11
+ end
12
+
13
+ def test_fails
14
+ refute true
15
+ end
16
+
17
+ def test_errors
18
+ raise "foo"
19
+ end
20
+
21
+ def test_flunks
22
+ flunk "this is pending"
23
+ end
24
+ end
25
+
26
+ class MinitestSample2 < Minitest::Test
27
+ def test_passes
28
+ assert true
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "rspec/autorun"
5
+ require "test_notifier"
6
+
7
+ describe "test" do
8
+ it "passes" do
9
+ expect(true).to be
10
+ end
11
+
12
+ it "passes too" do
13
+ expect(true).to be
14
+ end
15
+
16
+ it "fails" do
17
+ expect(false).to be
18
+ end
19
+
20
+ it "pending" do
21
+ expect(true).to be
22
+ end
23
+
24
+ it "raises" do
25
+ throw "error"
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "minitest/utils"
5
+ require "minitest/autorun"
6
+ require "test_notifier"
7
+
8
+ module Minitest
9
+ class Test
10
+ def unsupport_all_notifiers
11
+ Notifier.notifiers.each do |notifier|
12
+ next if notifier == Notifier::Noop
13
+
14
+ notifier.stubs(:supported?).returns(false)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class StatsMinitestTest < Minitest::Test
6
+ let(:stats) { TestNotifier::Stats.new(:minitest) }
7
+
8
+ test "returns success message" do
9
+ stats.options = {count: 10, assertions: 20}
10
+
11
+ assert_equal "10 tests, 20 assertions", stats.message
12
+ end
13
+
14
+ test "message with failing tests" do
15
+ stats.options = {count: 10, assertions: 20, failures: 5}
16
+
17
+ assert_equal "10 tests, 20 assertions, 5 failed", stats.message
18
+ end
19
+
20
+ test "message with error tests" do
21
+ stats.options = {count: 10, assertions: 20, errors: 5}
22
+
23
+ assert_equal "10 tests, 20 assertions, 5 errors", stats.message
24
+ end
25
+
26
+ test "message with pending tests" do
27
+ stats.options = {count: 10, assertions: 20, pending: 5}
28
+
29
+ assert_equal "10 tests, 20 assertions, 5 pending", stats.message
30
+ end
31
+
32
+ test "message with all types" do
33
+ stats.options = {
34
+ count: 6,
35
+ failures: 2,
36
+ errors: 3,
37
+ assertions: 20,
38
+ pending: 4
39
+ }
40
+
41
+ expected = "6 tests, 20 assertions, 2 failed, 3 errors, 4 pending"
42
+
43
+ assert_equal expected, stats.message
44
+ end
45
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class StatsTest < Minitest::Test
6
+ let(:stats) { TestNotifier::Stats.new(:rspec) }
7
+
8
+ test "returns success message" do
9
+ stats.options = {count: 10}
10
+
11
+ assert_equal "10 examples", stats.message
12
+ end
13
+
14
+ test "returns message with failing examples" do
15
+ stats.options = {count: 10, failures: 5}
16
+
17
+ assert_equal "10 examples, 5 failed", stats.message
18
+ end
19
+
20
+ test "returns message with pending examples" do
21
+ stats.options = {count: 10, pending: 5}
22
+
23
+ assert_equal "10 examples, 5 pending", stats.message
24
+ end
25
+
26
+ test "returns message with error examples" do
27
+ stats.options = {count: 10, failures: 5, errors: 5}
28
+
29
+ assert_equal "10 examples, 5 failed, 5 errors", stats.message
30
+ end
31
+
32
+ test "returns message with all types" do
33
+ stats.options = {count: 6, failures: 3, errors: 2, pending: 3}
34
+
35
+ assert_equal "6 examples, 3 failed, 3 pending, 2 errors", stats.message
36
+ end
37
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class TestNotifierTest < Minitest::Test
6
+ setup { unsupport_all_notifiers }
7
+ teardown { TestNotifier.default_notifier = :hud }
8
+
9
+ test "uses default notifier" do
10
+ Notifier::Knotify.stubs(:supported?).returns(true)
11
+ Notifier::Snarl.stubs(:supported?).returns(true)
12
+ TestNotifier.default_notifier = :snarl
13
+
14
+ assert_equal Notifier::Snarl, TestNotifier.notifier
15
+ end
16
+
17
+ test "outputs error message to when there's no supported notifier" do
18
+ Notifier.stubs(:notifier).returns(Notifier::Noop)
19
+ TestNotifier.silence_no_notifier_warning = false
20
+
21
+ _, err = capture_io do
22
+ TestNotifier.notify status: :fail, message: "You have failed!"
23
+ end
24
+
25
+ assert_includes err, TestNotifier::NO_NOTIFIERS_MESSAGE
26
+ end
27
+
28
+ test "doesn't output error message when silence is enabled" do
29
+ TestNotifier.silence_no_notifier_warning = true
30
+
31
+ $stderr.expects(:<<).never
32
+ Notifier::Noop.expects(:notify).at_least(1)
33
+
34
+ TestNotifier.notify status: :fail, message: "You have failed!"
35
+ end
36
+
37
+ test "sends notification to supported notifier" do
38
+ args = {
39
+ status: :fail,
40
+ message: "You have failed!",
41
+ title: TestNotifier::TITLES[:fail],
42
+ image: TestNotifier::IMAGES[:fail],
43
+ color: TestNotifier::COLORS[:fail]
44
+ }
45
+
46
+ Notifier::Snarl.stubs(:supported?).returns(true)
47
+ Notifier::Snarl.expects(:notify).with(args)
48
+
49
+ TestNotifier.notify status: :fail, message: "You have failed!"
50
+ end
51
+
52
+ test "sets symbol name for hud notifier (failed)" do
53
+ args = {
54
+ message: "You have failed!",
55
+ title: "Failed!",
56
+ image: "exclamationmark.triangle",
57
+ color: "orange",
58
+ status: :fail
59
+ }
60
+
61
+ Notifier::Hud.stubs(:supported?).returns(true)
62
+ Notifier::Hud.expects(:notify).with(args)
63
+
64
+ TestNotifier.notify status: :fail, message: "You have failed!"
65
+ end
66
+
67
+ test "sets symbol name for hud notifier (success)" do
68
+ args = {
69
+ message: "You passed!",
70
+ title: "Passed!",
71
+ image: "checkmark.circle",
72
+ color: "green",
73
+ status: :success
74
+ }
75
+
76
+ Notifier::Hud.stubs(:supported?).returns(true)
77
+ Notifier::Hud.expects(:notify).with(args)
78
+
79
+ TestNotifier.notify status: :success, message: "You passed!"
80
+ end
81
+
82
+ test "sets symbol name for hud notifier (error)" do
83
+ args = {
84
+ message: "You have errored!",
85
+ title: "Error!",
86
+ image: "xmark.octagon",
87
+ color: "red",
88
+ status: :error
89
+ }
90
+
91
+ Notifier::Hud.stubs(:supported?).returns(true)
92
+ Notifier::Hud.expects(:notify).with(args)
93
+
94
+ TestNotifier.notify status: :error, message: "You have errored!"
95
+ end
96
+ end
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.version = TestNotifier::Version::STRING.to_s
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Nando Vieira"]
10
- s.required_ruby_version = ">= 2.7"
11
- s.email = ["fnando.vieira@gmail.com"]
10
+ s.required_ruby_version = ">= 3.4"
11
+ s.email = ["me@fnando.com"]
12
12
  s.homepage = "http://rubygems.org/gems/test_notifier"
13
13
  s.summary = "Display system notifications (dbus, terminal notifier, " \
14
14
  "snarl, and more) after running tests."
@@ -18,15 +18,16 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.metadata["rubygems_mfa_required"] = "true"
20
20
  s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
21
  s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
23
22
  File.basename(f)
24
23
  end
25
24
  s.require_paths = ["lib"]
26
25
 
27
26
  s.add_dependency "notifier"
27
+ s.add_development_dependency "minitest-utils"
28
+ s.add_development_dependency "mocha"
28
29
  s.add_development_dependency "rake"
29
- s.add_development_dependency "rspec", ">= 3.0.0"
30
+ s.add_development_dependency "rspec"
30
31
  s.add_development_dependency "rubocop"
31
32
  s.add_development_dependency "rubocop-fnando"
32
33
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-02-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: notifier
@@ -24,6 +23,34 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: minitest-utils
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: mocha
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
27
54
  - !ruby/object:Gem::Dependency
28
55
  name: rake
29
56
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +71,14 @@ dependencies:
44
71
  requirements:
45
72
  - - ">="
46
73
  - !ruby/object:Gem::Version
47
- version: 3.0.0
74
+ version: '0'
48
75
  type: :development
49
76
  prerelease: false
50
77
  version_requirements: !ruby/object:Gem::Requirement
51
78
  requirements:
52
79
  - - ">="
53
80
  - !ruby/object:Gem::Version
54
- version: 3.0.0
81
+ version: '0'
55
82
  - !ruby/object:Gem::Dependency
56
83
  name: rubocop
57
84
  requirement: !ruby/object:Gem::Requirement
@@ -83,44 +110,37 @@ dependencies:
83
110
  description: Display system notifications after running tests. It works on Mac OS
84
111
  X, Linux and Windows. Powerful when used with autotest or guard.
85
112
  email:
86
- - fnando.vieira@gmail.com
113
+ - me@fnando.com
87
114
  executables: []
88
115
  extensions: []
89
116
  extra_rdoc_files: []
90
117
  files:
91
118
  - ".gitignore"
92
- - ".rspec"
93
119
  - ".rubocop.yml"
94
120
  - Gemfile
95
121
  - README.md
96
122
  - Rakefile
123
+ - lib/minitest/test_notifier_plugin.rb
97
124
  - lib/test_notifier.rb
98
125
  - lib/test_notifier/runner.rb
99
- - lib/test_notifier/runner/autotest.rb
100
126
  - lib/test_notifier/runner/minitest.rb
101
127
  - lib/test_notifier/runner/rspec.rb
102
- - lib/test_notifier/runner/rspec2.rb
103
- - lib/test_notifier/runner/rspec3.rb
104
- - lib/test_notifier/runner/spec.rb
105
- - lib/test_notifier/runner/test_unit.rb
106
128
  - lib/test_notifier/stats.rb
107
129
  - lib/test_notifier/version.rb
108
130
  - resources/error.png
109
131
  - resources/fail.png
110
- - resources/register-growl.scpt
111
132
  - resources/success.png
112
- - spec/spec_helper.rb
113
- - spec/stats/minitest_spec.rb
114
- - spec/stats/rspec1_spec.rb
115
- - spec/stats/rspec_spec.rb
116
- - spec/stats/test_unit_spec.rb
117
- - spec/test_notifier_spec.rb
133
+ - test/fixtures/minitest_sample_test.rb
134
+ - test/fixtures/rspec_sample_spec.rb
135
+ - test/test_helper.rb
136
+ - test/test_notifier/stats_minitest_test.rb
137
+ - test/test_notifier/stats_rspec_test.rb
138
+ - test/test_notifier_test.rb
118
139
  - test_notifier.gemspec
119
140
  homepage: http://rubygems.org/gems/test_notifier
120
141
  licenses: []
121
142
  metadata:
122
143
  rubygems_mfa_required: 'true'
123
- post_install_message:
124
144
  rdoc_options: []
125
145
  require_paths:
126
146
  - lib
@@ -128,22 +148,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
148
  requirements:
129
149
  - - ">="
130
150
  - !ruby/object:Gem::Version
131
- version: '2.7'
151
+ version: '3.4'
132
152
  required_rubygems_version: !ruby/object:Gem::Requirement
133
153
  requirements:
134
154
  - - ">="
135
155
  - !ruby/object:Gem::Version
136
156
  version: '0'
137
157
  requirements: []
138
- rubygems_version: 3.3.7
139
- signing_key:
158
+ rubygems_version: 4.0.3
140
159
  specification_version: 4
141
160
  summary: Display system notifications (dbus, terminal notifier, snarl, and more) after
142
161
  running tests.
143
- test_files:
144
- - spec/spec_helper.rb
145
- - spec/stats/minitest_spec.rb
146
- - spec/stats/rspec1_spec.rb
147
- - spec/stats/rspec_spec.rb
148
- - spec/stats/test_unit_spec.rb
149
- - spec/test_notifier_spec.rb
162
+ test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_notifier"
4
-
5
- Autotest.add_hook :ran_command do |at|
6
- content = at.results.to_s
7
-
8
- rspec_re = /(\d+) examples?, (\d+) failures?(, (\d+) pendings?)?/
9
- test_unit_re = /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/
10
-
11
- rspec_matches = content.match(rspec_re)
12
- test_unit_matches = content.match(test_unit_re)
13
-
14
- if rspec_matches
15
- _, examples, failures, _, pending = *rspec_matches
16
-
17
- stats = TestNotifier::Stats.new(
18
- :spec,
19
- {
20
- count: examples,
21
- failures: failures,
22
- pending: pending
23
- }
24
- )
25
-
26
- unless examples.to_i.zero?
27
- TestNotifier.notify(status: stats.status, message: stats.message)
28
- end
29
- elsif test_unit_matches
30
- _, tests, assertions, failures, errors = *test_unit_matches
31
-
32
- stats = TestNotifier::Stats.new(
33
- :test_unit,
34
- {
35
- count: tests,
36
- assertions: assertions,
37
- failures: failures,
38
- errors: errors
39
- }
40
- )
41
-
42
- unless tests.to_i.zero?
43
- TestNotifier.notify(status: stats.status, message: stats.message)
44
- end
45
- end
46
- rescue StandardError => error
47
- puts error
48
- puts error.backtrace
49
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_notifier"
4
- require "rspec/core/formatters/base_text_formatter"
5
-
6
- module RSpec
7
- module Core
8
- module Formatters
9
- class BaseTextFormatter
10
- alias dump_summary_original dump_summary
11
-
12
- def dump_summary(duration, example_count, failure_count, pending_count)
13
- dump_summary_original(
14
- duration,
15
- example_count,
16
- failure_count,
17
- pending_count
18
- )
19
-
20
- return if example_count.zero?
21
-
22
- failure_filter = proc do |error|
23
- error
24
- .instance_variable_get(:@exception)
25
- .instance_of?(RSpec::Expectations::ExpectationNotMetError)
26
- end
27
-
28
- error_filter = proc do |error|
29
- %w[
30
- RSpec::Expectations::ExpectationNotMetError
31
- NilClass
32
- ].include?(error.instance_variable_get(:@exception).class.name)
33
- end
34
-
35
- stats = TestNotifier::Stats.new(
36
- :rspec,
37
- {
38
- count: example_count,
39
- failures: examples.count(&failure_filter),
40
- pending: pending_count,
41
- errors: examples.count(&error_filter)
42
- }
43
- )
44
-
45
- TestNotifier.notify(status: stats.status, message: stats.message)
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_notifier"
4
- require "rspec/core"
5
- require "rspec/core/formatters/base_text_formatter"
6
-
7
- module RSpec
8
- module Core
9
- module Formatters
10
- class BaseTextFormatter
11
- alias dump_summary_original dump_summary
12
-
13
- def dump_summary(options)
14
- dump_summary_original(options)
15
-
16
- example_count = options.example_count
17
- pending_count = options.pending_count
18
- examples = options.examples
19
-
20
- return if example_count.zero?
21
-
22
- failure_filter = proc do |error|
23
- error
24
- .instance_variable_get(:@exception)
25
- .instance_of?(RSpec::Expectations::ExpectationNotMetError)
26
- end
27
-
28
- error_filter = proc {|e|
29
- %w[
30
- RSpec::Expectations::ExpectationNotMetError
31
- NilClass
32
- ].include?(e.instance_variable_get(:@exception).class.name)
33
- }
34
-
35
- stats = TestNotifier::Stats.new(
36
- :rspec,
37
- {
38
- count: example_count,
39
- failures: examples.count(&failure_filter),
40
- pending: pending_count,
41
- errors: examples.count(&error_filter)
42
- }
43
- )
44
-
45
- TestNotifier.notify(status: stats.status, message: stats.message)
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_notifier"
4
- require "spec/runner/formatter/base_text_formatter"
5
-
6
- module Spec
7
- module Runner
8
- module Formatter
9
- class BaseTextFormatter
10
- alias dump_summary_original dump_summary
11
-
12
- def dump_summary(duration, example_count, failure_count, pending_count)
13
- dump_summary_original(duration, example_count, failure_count,
14
- pending_count)
15
-
16
- return if example_count.zero?
17
-
18
- stats = TestNotifier::Stats.new(:spec, {
19
- count: example_count,
20
- failures: failure_count,
21
- pending: pending_count,
22
- errors: nil
23
- })
24
-
25
- TestNotifier.notify(status: stats.status, message: stats.message)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_notifier"
4
- require "test/unit/ui/console/testrunner"
5
-
6
- module Test
7
- module Unit
8
- module UI
9
- module Console
10
- class TestRunner
11
- alias finished_original finished
12
-
13
- def finished(elapsed_time)
14
- finished_original(elapsed_time)
15
-
16
- begin
17
- re = /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/
18
- _, tests, assertions, failures, errors = *@result.to_s.match(re)
19
- return if tests.to_i.zero?
20
-
21
- stats = TestNotifier::Stats.new(:test_unit, {
22
- count: tests,
23
- assertions: assertions,
24
- failures: failures,
25
- errors: errors
26
- })
27
-
28
- TestNotifier.notify(status: stats.status, message: stats.message)
29
- rescue StandardError => error
30
- puts error
31
- puts error.backtrace
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
Binary file
data/spec/spec_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "test_notifier"
5
-
6
- module SpecHelpers
7
- def unsupport_all_notifiers
8
- Notifier.notifiers.each do |notifier|
9
- unless notifier == Notifier::Placebo
10
- allow(notifier).to receive(:supported?).and_return(false)
11
- end
12
- end
13
- end
14
- end
15
-
16
- RSpec.configure do |config|
17
- config.include SpecHelpers
18
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe TestNotifier::Stats, "MiniTest" do
6
- subject(:stats) { TestNotifier::Stats.new(:minitest) }
7
-
8
- it "returns success message" do
9
- stats.options = {count: 10, assertions: 20}
10
- expect(stats.message).to eql("10 tests, 20 assertions")
11
- end
12
-
13
- it "message with failing examples" do
14
- stats.options = {count: 10, assertions: 20, failures: 5}
15
- expect(stats.message).to eql("10 tests, 20 assertions, 5 failed")
16
- end
17
-
18
- it "message with error examples" do
19
- stats.options = {count: 10, assertions: 20, errors: 5}
20
- expect(stats.message).to eql("10 tests, 20 assertions, 5 errors")
21
- end
22
-
23
- it "message with all types" do
24
- stats.options = {
25
- count: 6, failures: 2, errors: 3,
26
- assertions: 20
27
- }
28
- expect(stats.message).to eql("6 tests, 20 assertions, 2 failed, 3 errors")
29
- end
30
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe TestNotifier::Stats, "RSpec 1" do
6
- subject(:stats) { TestNotifier::Stats.new(:spec) }
7
-
8
- it "returns success message" do
9
- stats.options = {count: 10}
10
- expect(stats.message).to eql("10 examples")
11
- end
12
-
13
- it "returns message with failing examples" do
14
- stats.options = {count: 10, failures: 5}
15
- expect(stats.message).to eql("10 examples, 5 failed")
16
- end
17
-
18
- it "returns message with pending examples" do
19
- stats.options = {count: 10, pending: 5}
20
- expect(stats.message).to eql("10 examples, 5 pending")
21
- end
22
-
23
- it "returns message with all types" do
24
- stats.options = {count: 6, failures: 2, pending: 3}
25
- expect(stats.message).to eql("6 examples, 2 failed, 3 pending")
26
- end
27
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe TestNotifier::Stats, "RSpec" do
6
- subject(:stats) { TestNotifier::Stats.new(:rspec) }
7
-
8
- it "returns success message" do
9
- stats.options = {count: 10}
10
- expect(stats.message).to eql("10 examples")
11
- end
12
-
13
- it "returns message with failing examples" do
14
- stats.options = {count: 10, failures: 5}
15
- expect(stats.message).to eql("10 examples, 5 failed")
16
- end
17
-
18
- it "returns message with pending examples" do
19
- stats.options = {count: 10, pending: 5}
20
- expect(stats.message).to eql("10 examples, 5 pending")
21
- end
22
-
23
- it "returns message with error examples" do
24
- stats.options = {count: 10, failures: 5, errors: 5}
25
- expect(stats.message).to eql("10 examples, 5 failed, 5 errors")
26
- end
27
-
28
- it "returns message with all types" do
29
- stats.options = {count: 6, failures: 3, errors: 2, pending: 3}
30
- expect(stats.message).to eql("6 examples, 3 failed, 3 pending, 2 errors")
31
- end
32
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe TestNotifier::Stats, "TestUnit" do
6
- subject(:stats) { TestNotifier::Stats.new(:test_unit) }
7
-
8
- it "returns success message" do
9
- stats.options = {count: 10, assertions: 20}
10
- expect(stats.message).to eql("10 tests, 20 assertions")
11
- end
12
-
13
- it "returns message with failing examples" do
14
- stats.options = {count: 10, assertions: 20, failures: 5}
15
- expect(stats.message).to eql("10 tests, 20 assertions, 5 failed")
16
- end
17
-
18
- it "message with error examples" do
19
- stats.options = {count: 10, assertions: 20, errors: 5}
20
- expect(stats.message).to eql("10 tests, 20 assertions, 5 errors")
21
- end
22
-
23
- it "message with all types" do
24
- stats.options = {
25
- count: 6, failures: 2, errors: 3,
26
- assertions: 20
27
- }
28
- expect(stats.message).to eql("6 tests, 20 assertions, 2 failed, 3 errors")
29
- end
30
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe TestNotifier do
6
- before { unsupport_all_notifiers }
7
-
8
- it "uses default notifier" do
9
- allow(Notifier::Hud).to receive(:supported?).and_return(true)
10
- allow(Notifier::Snarl).to receive(:supported?).and_return(true)
11
- TestNotifier.default_notifier = :snarl
12
-
13
- expect(TestNotifier.notifier).to eql(Notifier::Snarl)
14
- end
15
-
16
- it "outputs error message to $stderr when there's no supported notifier" do
17
- expect($stderr).to receive(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE)
18
- expect(Notifier::Placebo).to receive(:notify)
19
-
20
- TestNotifier.notify status: :fail, message: "You have failed!"
21
- end
22
-
23
- it "doesn't output error message when silence_no_notifier_warning is true" do
24
- TestNotifier.silence_no_notifier_warning = true
25
-
26
- expect($stderr).not_to receive(:<<)
27
- expect(Notifier::Placebo).to receive(:notify)
28
-
29
- TestNotifier.notify status: :fail, message: "You have failed!"
30
- end
31
-
32
- it "sends notification to supported notifier" do
33
- args = {
34
- status: :fail,
35
- message: "You have failed!",
36
- title: TestNotifier::TITLES[:fail],
37
- image: TestNotifier::IMAGES[:fail],
38
- color: TestNotifier::COLORS[:fail]
39
- }
40
-
41
- allow(Notifier::Snarl).to receive(:supported?).and_return(true)
42
- expect(Notifier::Snarl).to receive(:notify).with(args)
43
-
44
- TestNotifier.notify status: :fail, message: "You have failed!"
45
- end
46
-
47
- it "sets symbol name for hud notifier (failed)" do
48
- args = {
49
- message: "You have failed!",
50
- title: "Failed!",
51
- image: "exclamationmark.triangle",
52
- color: "orange",
53
- status: :fail
54
- }
55
-
56
- allow(Notifier::Hud).to receive(:supported?).and_return(true)
57
- expect(Notifier::Hud).to receive(:notify).with(args)
58
-
59
- TestNotifier.notify status: :fail, message: "You have failed!"
60
- end
61
-
62
- it "sets symbol name for hud notifier (success)" do
63
- args = {
64
- message: "You passed!",
65
- title: "Passed!",
66
- image: "checkmark.circle",
67
- color: "green",
68
- status: :success
69
- }
70
-
71
- allow(Notifier::Hud).to receive(:supported?).and_return(true)
72
- expect(Notifier::Hud).to receive(:notify).with(args)
73
-
74
- TestNotifier.notify status: :success, message: "You passed!"
75
- end
76
-
77
- it "sets symbol name for hud notifier (error)" do
78
- args = {
79
- message: "You have errored!",
80
- title: "Error!",
81
- image: "xmark.octagon.fill",
82
- color: "red",
83
- status: :error
84
- }
85
-
86
- allow(Notifier::Hud).to receive(:supported?).and_return(true)
87
- expect(Notifier::Hud).to receive(:notify).with(args)
88
-
89
- TestNotifier.notify status: :error, message: "You have errored!"
90
- end
91
- end